Backups are a must! I’ve said this time and time again and I’ll say it every time backup are the topic: One can never have enough backups.

There are a lot of advanced / dedicated backup programs out there, but for the simple task sometimes simpler programs are simpler… Here is where 7zip (a powerful multi-platform archiver) comes in – readily available for the Linux platform via the p7zip package (on RHEL-compatible distros).

I’m using 7zip to create full monthly backups and differential daily backups. Differential backups are good because they only hold the differences from the target existing archive. But you don’t want to rely entirely on differential backups as you’ll also need to keep the first ever complete backup (which may become very old very fast).

Assuming you want to backup you www folder, the following script should to a very good job at it:

where,

  • DIRR is the backup folder
  • /var/www is the www folder to be backup up
  • -xr!www[...]somebigfolder and -xr!www[...]/anotherdomain.tld are exclusion patterns; somebigfolder and anotherdomain.tld (and all their contents) will be excluded from the backup

The script creates 2 separate archive sets:

  • a full monthly backup, named www-YYYYMM.7z
  • a daily (nightly) differential backup, named www-YYYYMMDD.7z, which will contain just the changes since the previous monthly archive was done; if you run it every day, it will create one monthly archive at the beginning of the month and a differential one each day after.

A plus of the script is that it creates the full monthly archive the first time it is run that month, so you can schedule to run at various time periods. To restore to a particular date, you’ll need the monthly archive plus the one from the day you want to restore to.

WARNING: 7zip does not save filesystem specific information like permissions and ownership. Do not use this script and 7zip to perform system or mission critical backups.

Source: (1).

 

 

Leave a Reply