1

Please consider I'm not sys admin so I have only limited experience with the tools involved, I know there are similar question but I cannot find anything that suit my needs.

In a similar question somebody suggested backup2l but looks outdated and not well documented. ( I need something like this but incremental)

So I would like to understand what are the best precooked solution or create a simple bash script for this task. (unfortunately I'm not good on bash)

Target
I would like to do an incremental backup of the public_html dir of my site.
The idea it to store an incremental backup on daily basis and store 1 month only (but keep the previous month):

2015-10/  -> contains a full/incremental backup of last month
2015-11/  -> contains a full/incremental backup of current month

so at begin of Dec. 2015-10 get deleted and 2015-12 get created.

Scenario
I'm on a shared server with limited cli tool ( rsync/tar) and only 16gb.
I need to backup my magento site.
Since the code is hosted on git I'm interested to keep daily backup only of the media folder ( exclude media/product/cache )

Right now I'm using this script to create a daily backup of the media folder ( but it is not incremental )

#!/bin/bash
# Daily backup script

# Create some needed variable
day=$(date +%F)
File="/home/me/backup/files_$day.tar.gz"
File_media="/home/me/backup/catalog_images_$day.tar.gz"
Folder="/home/me/"
Exclude_media_cache="public_html/media/catalog/product/cache"

# Backup Media
echo "-- Creating Catalog Image Backup ..."
tar -pczf $File_media -C $Folder public_html/media/catalog --exclude="$Exclude_media_cache"

1 Answer 1

3

This is too common a problem to be rolling shell scripts. Use one of the many tools designed for the purpose.

I recommend rdiff-backup for such things.

To control the amount of incremental backups it creates, and thus control disk space, use its --remove-older-than flag.

4
  • thx, I will give a try. What about this pointsoftware.ch/… ?
    – Francesco
    Oct 31, 2015 at 3:33
  • @Francesco: If you need to be able to see incremental backup directories as they were on the date on the directory, then something like that script will work better for you. But if you are not trying to roll back to a specific date, but more often just need to see the current backup and possibly older versions of the file, rdiff-backup is better, because it doesn't create unnecessary directory entries. All those hard links are not free. Pay for them only if you need them. Oct 31, 2015 at 3:37
  • sorry I don't get you, what you meant "those hard links are not free" ?
    – Francesco
    Oct 31, 2015 at 5:58
  • 1
    @Francesco: Every hard link takes a directory entry. Every directory entry is another thing for the filesystem to manage. If you have 100 incremental backups, you multiply the number of files the OS has to manage by 100. Fortunately, OSes use logarithmic data structures to manage this, so it doesn't slow everything down by 100x, but it does add to the load, and disk space. Small, but nonzero. Oct 31, 2015 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.