Skip to content

Backup solution with snapshots using hard links

License

GPL-3.0, GPL-3.0 licenses found

Licenses found

GPL-3.0
LICENSE
GPL-3.0
COPYING
Notifications You must be signed in to change notification settings

ronligt/snapsync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snapsync

The snapsync system is a backup system that creates hourly snapshots (backups) of a given directory using hard links to files in snapshots created earlier to save storage. New or modified files are included in the snapshot and removed files are deleted from the snapshot.

A cleanup script is included to preserve snapshots via a retention scheme. By default this scheme only keeps the following snapshots:

  1. the oldest one
  2. the first backup in a month
  3. the first backup on every Sunday [SNAPSYNC_DOW] of the last 4 [SNAPSYNC_MAXWEEK] weeks
  4. Every first backup of the last 7 [SNAPSYNC_MAXDAY] days
  5. Every backup in the last 24 [SNAPSYNC_MAXHOUR] hours

Using the environment variables given inside the square brackets in the rules above you can modify this scheme.

All files in the snapshots are added to a local locate database enabling users to find their files (Locate).

Usage

  1. create a snapsync directory for all snapshots, e.g. /snapsync

  2. create a specific directory inside snapsync for each snapsynced directory, e.g. /snapsync/home

  3. add the following lines to the crontab jobs of the root for each directory (in this example /home):

    15 * * * * snapsync.sh /home /snapsync/home >> /snapsync/home/snapsync.log
    45 * * * * cleanup.sh /snapsync/home >> /snapsync/home/snapsync.log

For the exact usage of the script run the scripts snapsync.sh and cleanup.sh with arguments to get more information.

Runtime errors are added to error.log inside the snapsync directory.

A sample logrotate script (logrotate_snapsync) is included which can be saved in /etc/logrotate.d/snapsync.

Locate

After each modification to the snapsync system the locate database (mlocate.db) is updated. This allows users to find their files and/or directory using the following command:

locate --database=/snapsync/home/mlocate.db -b <filename>

Dependencies

  • standard Linux or macOS environment. This system has not been tested with Windows.
  • bash
  • rsync
  • updatedb (part of locate)

Separating source and backup

This system allows for easy separation of the source hardware and snapsync (backup) hardware. As the system will always copy new or modified files via rsync these copies can also be stored on attached external devices like usb-disks or network storages. Note that the snapsync.sh script must be run on the source system and the cleanup.sh script can be run on the snapsync system.

License and Copyright

                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

Please read the LICENSE file for more information.

About

Backup solution with snapshots using hard links

Topics

Resources

License

GPL-3.0, GPL-3.0 licenses found

Licenses found

GPL-3.0
LICENSE
GPL-3.0
COPYING

Stars

Watchers

Forks

Languages