2

I have some remote servers and one backup server, I'm using Rsnapshot to do the remote backup on the backup server. In my plan, I want to run shell script to compress files first, then Rsnapshot can backup the compressed files. In the Rsnapshot config file, I found cmd_preexec, and I want to use it, but I don't know how to write the compression script. Can anyone help me with the script?

Any help would be grateful. Thank You.

technoob
  • 142
  • 1
  • 14

1 Answers1

5

The question is, WHY do you want compression?

Compression to improve transfer speed

If you want to compress the speed of the transfer, you can add a parameter to rsync to enable on-the-fly compression during the transfer:

rsync_short_args -az (source)

Compression to reduce space requirements on backup disk

rsnapshot seems to deal rather badly with compressed backups. I found a solution to compress files on the backup server:

(...) SOME of the files in the (2nd & beyond) archive sets can be compressed, those that aren't in a linked set.

find daily.1 -links 1 -size +1M ! -name "*.bz2" -print | grep -v \.svn | xargs pbzip2 -v

Revert

find daily.1 -links 1 -name "*.bz2" -print | xargs pbzip2 -d -v

Only run that against the 2nd archive set (e.g hourly.1, daily.1 or weekly.1) of the shortest in your configuration.

(source).

If you want to reduce the space requirements without interference, you could also use transparent compression on the destination file system itself. I know that ZFS and BTRFS offer this natively. If your hard drive is an SSD, it might already do a transparent compression internally for all your files.

Slizzered
  • 814
  • 6
  • 16
  • Thanks for the answer, i used to use rysnc_short_args -az, but I didn't see any difference. Maybe I used to test with some really small files. – technoob Apr 16 '15 at 22:30
  • There are multiple reasons why it might have no effect. Maybe the file-type was not ideal for compression? Media files (pictures, video, music) are already very compressed, so additional compression through `rsync` might have almost no effect – Slizzered Apr 16 '15 at 22:51