“How to backup my files” is something you definitely want to know. Especially if you’ve ever suffered the pain of losing your files. There’s lots of expensive plugins and cloud-based solutions but that’s not for everyone, and some of these have inherent security risks. As someone who’s worked in IT for many years (and suffered from disk failure and data loss!) I decided to build my own solution. It worked so well that friends wanted it for their business and so I’ve made it into a command line script, which takes the pain out of managing your backups. I’ve made it FREE for anyone who wants to use it.
Easy Way to Backup Files/Drive on Linux
Here’s the key things this script does:
- Once it is running there’s no need to do anything. Start and forget it.
- It allows you to keep offsite backups at an alternative location protecting your data in the case of disaster, eg. a fire, theft, or flood.
- You can have as many backup disks as you want and you don’t need to do any additional setup.
- It’s on-site, not offsite or on the cloud, so I don’t need to trust Google, Microsoft, or Amazon with your data.
- You’re 100% in control and you can fine tune it if you want. For example different backup schedules for work and personal data.
- It runs automatically 24/7 365 on a cheap bit of hardware (such as an old laptop running Linux).

Installation
/bin/backmeupz.sh move this to your preferred executable scripts location. e.g. /usr/bin/, /usr/local/bin/, or ~/Scripts/ Make sure the script is executable: chmod +x </path/to>/backmeupz.sh
/etc/backmeupz-demo.conf copy this to your preferred config location e.g. ~/.config/mfts/ or /etc/mfts/
Usage
./backmeupz.sh [-d] [-h] [-v] -c <path/to/config/file.conf>
- -d Delete files in backups (destination) which are no longer in the original (source)
- -h Show this Help.
- -c path/to/config/file.conf The path must be set for the config file. Values should be KEY=VALUE without spaces. One per line. No other lines in the config file. No comments etc.
- -v Write extra information to log file and stdout
Use Case Example
Imagine you have 3 1TB SSD external drives. You’ve set them up as LUKS encrypted ext4 Unix drives, so you have to enter a password to mount them. You name them MAIN, BACKUP01, and BACKUP02. On your machine you plug in MAIN and BACKUP01. MAIN is where you have your important data. You set this script up with the following config file settings in ~/.config/backmeupz.conf
- Z_SRCDRIVE=/media//MAINDISK
- Z_SRCDIR=/
- Z_DESTDIR=/Backup/
- Z_DESTDRIVES=/media//BACKUP??
- Z_LOGFILE=/var/log/backmeupz.log
Once a week you unmount the BACKUPnn drive and you give it to your friend/co-worker to store at their house. They give you back the other backup drive. You plug the backup drive you just got back from your friend into your machine and mount it. Run the script and now the second backup drive is synced. This means that you have 1 backup at your property and one backup off site (at your friend’s/co-worker’s). So now you’ve got the peace of mind knowing that worst-case scenario is that you only lose 1 week. Much better than losing everything. Plus if your MAINDISK fails, you’ve got everything backed up on BACKUP01 or BACKUP02 locally. There’s several bonus pros to this approach:
- If you’re using LUKS encryption (or something like Veracrypt) then if you lose your physical disk you know your data is safe (ssuming your password is v strong).
- You can take the MAINDISK offsite if you’re working remotely, knowing that your data is backed up back in your office/home.
- If you setup smbd (Samba) and point it at your MAIN disk then it means you’ve basically got a NAS setup with the equivalent of RAID1 (Mirrored)
- Use cron to run the script often, since it’s only syncing the difference each time. Obviously the first big sync may take hours, but the script won’t try and run again until it’s done.
In fairness its important to also understand any limitations:
- This does not provide point in time recovery, it is simply a macro (all or nothing) backup.
- If you delete something on MAINDISK and you’ve used the -d flag then it will delete it from the BACKUPnn DISKS
- You do need a little bit of knowledge to use this script. But not a lot. You’ll need to set a cron job to make sure the script is running regularly, and make sure you’ve created the config file (vim, emacs etc).
Some of the cool things this script does so you don’t have to:
- If the script is already running then it will prevent itself from running again. So there’s no risk of collision.
- If the MAIN disk isn’t present it will simply abort.
- You can set Z_DESTDIR to something like /Backup/ so that the backups are in a sub folder of the Backup Disks. Therefore you could manually put a time stamp on that if you want different times
- If any of the config file variables are missing it will let you know and abort.
- It will automatically set the perms on the log file and the config file to make sure you’ve not accidentally made them executable.
- You could have any number of Backup disks so long as they all have the same prefix and Z_DESTDRIVES has a suitable wildcard like ?? which would cover 00 to 99. So if you wanted to setup 3 or 4 backup disks in one go, you can!
- This script does use rsync so make sure its installed. As a rough guide 500GB takes about 2 to 4 hours on SSDs (obviously depends on your system/USB spec etc.)
- Use -v to see what’s happening, but know that it wont output the results of the sync up until the sync is finished.
- It automatically removes lock files from the backup. Useful as it may run while you’re working on a document and you don’t want the lock files preserved in the backups.
Donation & Support
https://buymeacoffee.com/zaretti Follow: https://zaretti.com/mister-freedom-tech/