📃 An incremential daily backup script using rsync
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



An incremental daily backup script using rsync

Copyright (c)2015 by Florian Beer

Version 1.01

This script comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See CC BY-NC-SA 4.0 for details. https://creativecommons.org/licenses/by-nc-sa/4.0/



Hactar is meant to be run daily, preferably when there is little load on your machine and rsyncs the contents of SOURCE to TARGET. Each day there will be a new subdirectory with the current date. Unchanged files will automatically be hardlinked to existing files to save diskspace.

Hactar sends a message tagged "hactar" to syslog stating SOURCE and TARGET on start and logs the total runtime when finished. This feature depends on logger and python being installed on your machine.


 -r NUM         number of days to keep old backups
 -e FILE        specify rsync excludes filename
 -v             increase verbosity
 -d             dry run
 -h             show this message
 -V             show version number


Source or target can be a remote directory (via SSH) or a local path. See rsync manpage for details.

 hactar -v -e my_exludes / /backup
 hactar example.com:/home /backup
 hactar /var/www example.com:/mnt/backup
 hactar -r 7 /var/log /backup/logs


  • Save this shell script to e.g. /usr/local/bin/hactar and make it executable: chmod +x /usr/local/bin/hactar

  • Optionally, create a new file called /etc/hactar.excludesand list all directories and/or filtermaps you don't need in your backup (see rsync manpage for details). My excludes contents:

  • Create a cron entry to run this script each day: crontab -e
0 3 * * * /usr/local/bin/hactar / /backup > /dev/null

This line calls the script each night at 3am and rsyncs the contents of / to /backup and sends you an email you if any errors occured during runtime.