Linux backups backup with bash, cron, rsync, and hard links. Inspired by http://www.mikerubel.org/computers/rsync_snapshots/
rsyncshot installs itself. To setup, just run the following commands:
wget https://raw.githubusercontent.com/cjennings/rsyncshot/main/rsyncshot
sudo bash ./rsyncshot setup
or simply clone this repo and run make install as root.
rsyncshot will install a default schedule:
- every hour at the top of the hour
- every day at noon
- every week on Sunday at noon
Edit the schedule with:
sudo crontab -e
Manual backups in the terminal with two arguments:
- TYPE is a way to group backups together. Automatic backups will have the TYPE as HOURLY, DAILY, or WEEKLY. But you can give your manual backups any TYPE you wish.
- MAX is the maximum number of backups before the oldest gets removed.
For instance:
rsyncshot manual 100
Specify which directories to backup by editing /etc/rsyncshot/includes.txt. The defaults are:
- /home - /etc - /usr/local/bin
Specify what filetype patterns to exclude by editing /etc/rsyncshot/excludes.txt. The defaults are:
- *.pyc - *.pyo - *.class - *.elc - *.o - *.tmp - .cache*
- rsyncshot separates backups by the machine’s name. Use one external drive to backup multiple machines without conflicts.
- rsyncshot leverages lockfiles to prevent overapping runs. A rsyncshot backup will not begin if a previous run is still in progress.
- rsyncshot will validate the specified source directories exist before beginning the backup.
- rsyncshot validates it’s backing up to a mounted drive. If the drive isn’t mounted, rsyncshot attempts to mount it.
- Backup directory permissions are changed to read-only to avoid mistaken deletion.
- rsyncshot logs the details of all runs to /var/log/rsyncshot.log.
- Bash
- Cron
- Rsync
- Grep
- Flock
- run ‘sudo make uninstall’ from the cloned directory.
- delete relevant cron entries as root
or become root and remove
- the /usr/local/bin/rsyncshot script
- the /etc/rsyncshot directory
- (optional) /var/log/rsyncshot.log
… and the relevant cron entries with crontab -e
rsyncshot isn’t production software, even though the underlying utilities are.