Rsync is a pretty reliable tool to sync files from your server to a remote server, but how would you validate that all files have been correctly backed up?
Log In Via Shell (Shared Hosting/Beginner)
Some instructions for beginners:
If you’re on Windows, download a tool called Putty and log into your server. The default port for this is port 22 and you will need the root password. If your webhost has secured the server you may be unable to log in with the root user but if your user account is a member of the wheel group you can log in using your regular username your webhost sent you.
It’s also possible your host changed the port from 22 to something else to prevent abuse or may require SSH keys. Contact your host to learn more.
DUH! Using DU Command To Compare Sizes
Duh! DU is easy to remember and allows you to check directory sizes.
The only parameter you need to remember to check directory sizes recursively, omitting sub-directories, is “s” and “h”.
- S is easy to remember. It stands for summary but could also stand for “suppress”
- H is easy to remember too. It stands for human readable and instead of showing just the bytes, it will convert it into the appropriate unit e.g. M, G.
So it would look like this:
DU -sh /home/backups
Use some tricks to remember the command. I keep forgetting the commands, but when I get bored of looking them up I try to come up with some word-games and stuff to remember it like DUH, no shit, which includes “DU SH”. Just some fun ways to be a little more productive when it comes to server administration.
RSYNC: Compare With Transfer Report
If you’re using rsync to create backups, it will tell you the exact size of files transferred at the end e.g.
sent 31.98M bytes received 165G bytes
Below that it will tell you the
total size which is the total size of all transferred files ON DISK.
Wait, why is the total size different from the received data size?
If you’re using Rsync with the option “-z” or “-compressed”, you can significantly speed up the file transfer because it will send compressed data. The actual backup data on disk will not be compressed and SHOULD match your server size.
You should probably also run du -sh again on the actual backup, not just the source directory.
Compare the directory size on your server with your backup size. The backup size should match or be a little larger. Sometimes files may take up more disk space on a different setup, so that’s something to keep in mind. For example my server has 197GB of files, but my backup is 198GB in size.