Backing up a Server Remotely Using Minimal Bandwidth

The server that runs this website (and a lot of others) also runs a lot of other services such as an IRC server, a Jabber server, NGINX (of course), and various other things. I like to take a lot of backups, especially since I'm not the best person in the area of security. With that, my old way of backing my my server was relatively painful. I had a script that tarred and compressed each service directory individually and move it to a secure location on my web server for download. After download, the script would remove the backup, and continue to the next.

The problem with this method is that it consumes a lot of bandwidth and time. By the time I have downloaded everything, I have used up several gigabytes of bandwidth. I don't mind so much about the bandwidth though. What's important is the time and interraction it takes.

Enter the Light Bulb...

I've been using rsync for some time now to mirror my laptop to my server at home. For some reason, it never occurred to me to use rsync with a private key to log in to my server and download the deltas to my local machine. If I want a single compressed tar file for a backup, all I have to do is backup my local server's copy of everything rather than doing it on my web server and downloading that. Ending this already too long blog post on this simple topic, here's the rsync command I'm using...

sync -avP --delete --chmod=g+rx --rsh="ssh -p1234 -i ~/.ssh/id_rsa.pdeb.user" user@server.net:/dir1 /home/server/dir1

A Quick Explanation

Written on: 2025-02-28 17:18:51 -0700

Last edited: 2025-03-02 05:44:17 UTC