📁 Check File Count in Backup Directory

This guide walks you through checking the number of backup files in a directory, especially useful when verifying restored or archived accounts.

Step-by-Step Instructions

  1. List home directories (or navigate to user directory):
[user@backup ~]$ ls
access-logs  backups  etc  logs  mail  public_ftp  public_html  ssl  tmp  www
  1. Navigate to the backups directory:
[user@backup ~]$ cd backups
  1. List the contents to see available backup archives or folders:
[user@backup backups]$ ls
example1.tar  server1  server2  server3  server4  example2.tar
  1. Navigate into the relevant server folder (e.g. server3):
[user@backup backups]$ cd server3
  1. List the available backup dates:
[user@backup server3]$ ls
2025-07-01
  1. Enter the backup date folder:
[user@backup server3]$ cd 2025-07-01
  1. List the account backup tar files:
[user@backup 2025-07-01]$ ls
accounts
  1. Go to the accounts directory:
[user@backup 2025-07-01]$ cd accounts
  1. List the tar files to confirm their presence:
[user@backup accounts]$ ls
account1.tar  account2.tar  account3.tar  account4.tar ...
  1. Count the number of .tar files:
[user@backup accounts]$ ls -1 | wc -l
29

If you run the command again after more backups are added:

[user@backup accounts]$ ls -1 | wc -l
31

✅ Notes

  • ls -1 ensures each result is printed on a new line.
  • wc -l counts the number of lines (i.e. files).
  • This is useful to verify all expected accounts were backed up or restored.
Scroll to Top