Ubuntu – Any tool that helps me do housekeeping on backups folder

17.10backupdata-recoveryrsynctar

Is there a tool or script I can use on a folder with a bunch of files. Files are added to this folder almost hourly. The tool should be "housekeeping":

  • Leave all files timestamped within the last 24 hours

  • Leave some (n) files that's a month old

  • Leave some (n) files that's an year old

  • Delete the rest

( n can be 1 for now for the sake of simplicity )

The idea is, when a data corruption/loss happens, I can go back to

  • a state (any available) from the last 24 hours

  • a state (if available) from 1 month ago

  • a state (if available) from 1 year ago

Best Answer

Expanding on the tip by Andrea, duplicity might be designed to address needs closer to mine. From http://duplicity.nongnu.org/duplicity.1.html (the last command looks promising):

Here is an example of a backup, using sftp to back up /home/me to some_dir on the other.host machine:

    duplicity /home/me sftp://uid@other.host/some_dir

If the above is run repeatedly, the first will be a full backup, and subsequent ones will be incremental. To force a full backup, use the full action:

    duplicity full /home/me sftp://uid@other.host/some_dir

or enforcing a full every other time via --full-if-older-than <time> , e.g. a full every month:

    duplicity --full-if-older-than 1M /home/me/sftp://uid@other.host/some_dir

Upate: Today I found this interesting article http://www.tarsnap.com/helper-scripts.html I believe what I'm trying to achieve is this https://en.wikipedia.org/wiki/Backup_rotation_scheme#Grandfather-father-son The article lists some tools. Update2: This script is interesting https://help.ubuntu.com/lts/serverguide/backups-shellscripts-rotation.html

Related Question