Saturday, March 20, 2010

BackInTime on CentOS 5.x

Back In Time is a simple backup tool geared mostly toward Linux desktop. Only Debian/Ubuntu binary packages are available from the official website.

I like Back In Time because it uses standard Linux tools like rsync,diff and cp to create backups and heavily utilizes hard-links to save space on the backup media.

I wanted to install it on a CentOS 5.x host and decided to create an RPM so others can use it on RPM based distros.

Spec File: backintime-cli.spec
Source RPM: backintime-cli-0.9.26-1.src.rpm
x86 RPM: backintime-cli-0.9.26-1.rhel5.i386.rpm

Configuration
Configuration file is located in /etc/backintime/config. I haven't yet found any useful documentation. The included config file was generated by the KDE4 GUI client. I removed many of the GUI specific configuration lines. If you come across good documentation, please leave a comment.

If you run /usr/bin/backintime as root, it uses /etc/backintime/config for configuration.
If you wish to run backintime as a regular user, copy the /etc/backintime/config file to ~/.config/backintime/config.

Here is what I have managed to figure out from experimenting using the GUI client:

config.version=2
snapshots.automatic_backup_mode=20
snapshots.cron.nice=true

# Manually run snapshots are not removed automatically

snapshots.dont_remove_named_snapshots=true
snapshots.exclude_patterns=*.backup*:*~

# Useful if you have mixed snapshot frequencies

snapshots.expert.per_directory_schedule=true

#0-manual,10-hourly,20-daily,30-weekly,40-monthly
# [file/folder]|[snapshot frequency]

snapshots.include_folders=/etc|30:/home:|20:/root|30:/var/named|40
snapshots.min_free_space.enabled=true

# 10=Mb, 20=Gb

snapshots.min_free_space.unit=20

# Maintain minimum of 1G free space on destination

snapshots.min_free_space.value=1
snapshots.notify.enabled=true

# Backup destination. Create 'backintime' folder manually.

snapshots.path=/backup
snapshots.remove_old_snapshots.enabled=true

# 20=days,30=weeks,80=years

snapshots.remove_old_snapshots.unit=30

# Remove backups older than 27 weeks

snapshots.remove_old_snapshots.value=27

# keep all snapshots from today & yesterday
# keep one snapshot for the last week and one for two weeks ago
# keep one snapshot per month for all previous months of this year
# keep one snapshot per year for all previous years

snapshots.smart_remove=true

Sample run:

[root@lamp32 ~]# backintime -b /etc
Back In Time
Version: 0.9.26

Back In Time comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type `backintime --license' for details.

INFO: Lock
INFO: Include folders: ['/etc']
INFO: Ignore folders: []
INFO: Last snapshots: {}
INFO: Compare with old snapshot: 20100320-181730
INFO: Command "rsync -aEAX -i --dry-run --chmod=Fa-w,D+w --whole-file --delete --exclude="/backup" --exclude="/root/.
local/share/backintime" --include="/etc/" --exclude="*.backup*" --exclude="*~" --include="/etc/**" --exclude="*" / "/bac
kup/backintime/20100320-181730/backup/"" returns 0
INFO: Create hard-links
INFO: Command "cp -al "/backup/backintime/20100320-181730/backup/"* "/backup/backintime/new_snapshot/backup/"" returns 0
INFO: Call rsync to take the snapshot
INFO: Command "rsync -aEAX -v --delete-excluded --chmod=Fa-w,D+w --whole-file --delete --exclude="/backup" --exclude="/root/.local/share/backintime" --include="/etc/" --exclude="*.backup*" --exclude="*~" --include="/etc/**" --exclude="*" / "/backup/backintime/new_snapshot/backup/"" returns 0
INFO: Save permissions
INFO: Remove backups older than: 20090907-000000
INFO: [smart remove] keep all >= 20100319-000000
INFO: [smart remove] keep first >= 20100308-000000 and <>= 20100301-000000 and <>= 20100101-000000 and <>= 20100201-000000 and <>

Hope this helps someone looking to run backintime on RHEL/CentOS.

Cheers,
VVK

3 comments:

  1. Thanks for the post. It works.

    ReplyDelete
  2. Hi,

    Great tutorial. I noticed though that permissions and ownerships are not preserved. Is this easy to fix in one of the Python scripts?

    Cheers

    ReplyDelete
  3. @Evert

    As far as I know, backintime uses the 'archive' option for rsync.

    As you can see in the 'Sample Run' section of this post, backintime calls rsync with '-aEAX' options:

    According to rsync man pages:
    -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)

    If you execute backintime as root, and then restore files from that backup as a normal user, I don't think it will change the ownership of those files to root.

    Thanks,
    VVK

    ReplyDelete