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