RootConsole.net

advices, tips, blog

  • Home

How to do backup with rsync and keep a copy of modified files?

Posted by Admin on April 22, 2016
Posted in: Servers, Shell, Storage, Tools. Tagged: backup, rsync.

Rsync is a very powerful  backup tool. It can significantly speed up backup process and minimize amount of data transferred during synchronization. In most cases rsync is used to make incremental backups, but it also has another interesting option which gives you ability to keeping old versions of files on backup server. Mentioned option is ‘–backup’ or simply ‘-b’.

That option is commonly used with ‘–backup-dir’ option which points a directory name where old files will be archived. Another useful option is ‘–suffix’ – it’s a suffix string (may be a date) appended to names of all archived files.

Let’s take a look on the example:

rsync -vzrb --backup-dir=_old_ --suffix=$(date+_%F-%T) --update --times /path/to/source backupuser@1.2.3.4:./path/to/destination

The above example uses two additional options: ‘–update’ and ‘–times’. First option is used to transfer only files that have newer modification date than files that was already backed up. Second option preserve modification times of transferred files.

Posts navigation

← How to convert SSL certificate between DER and PEM formats?
Multiple Postfix instances (with SELinux) →
  • or
    BTC
    1BLAWYYBP9ZGUwsJigtqW7JWLoaFFfZhMp
  • Contact

Proudly powered by WordPress Theme: Parament by Automattic.