While setting up a new development server recently, I needed to implement an automated backup of files and database tables to a local hard drive.
My first instinct was to write a cron job using
rsync. This worked fine, except that file permissions got messed up.
rsync will preserve ownership and permissions if I store the backup locally or on another server via SSH, but it falls down when storing to an attached hard drive by changing ownership and setting permissions on everything to
777. It also resorts to copying files in full, instead of actually syncing changes. In other words, this was not a viable solution.
After a quick search, I found a new service that can help: BackupBird.com. Setup literally takes only a few seconds, and the app will handle both file and database backups. I chose to store my files on a local disk attached to the server, however BackupBird also supports storing to numerous cloud providers.
Best of all, a single-server account is free!
Fwiw, there is one shortcoming: it copies entire files rather than only syncing the changes. I can overlook this for now since I’m on a dev server, but this might be a concern for a production server.