Differences

This shows you the differences between two versions of the page.

Link to this comparison view

backup [2012/10/17 00:32] (current)
Line 1: Line 1:
 +======= Simple backupscript utilizing rsync and hardlinks =======
  
 +===== Synopsis ======
 +
 +Backup remote machines using ssh and rsync, utilizing hardlinks for files that has not changed since last backup
 +
 +===== Configuration =====
 +
 +<​code>​
 +BACKUPUSER=backup
 +BASEDIR=/​backup/​
 +CONFDIR=/​usr/​local/​etc/​backup
 +DIR="/​etc /​usr/​local/​etc"​
 +</​code>​
 +
 +^ setting ^ description ^
 +| backupuser | is the user rsync users to connect to the remote machine, change this to the user you want to use |
 +| basedir | is the directory your backups are stored in. A file hieracy will be created here /​{basedir}/​{servername}/​{date}/​{directory} |
 +| confdir | is the directory with local configuration files (excludes and per-host configuration) |
 +| dir | default directories to backup - this can be changed on a per-host or hostgroup basis |
 +
 +For per-host configuration you need to create ''​hostconf.sh''​ in ''​$CONFDIR''​ (default is ''/​usr/​local/​etc/​backup/​hostconf.sh''​)
 +
 +This file needs a host_conf function which will be called with the hostname as an option
 +backup script will run fine without this initial configuration
 +
 +example:
 +<​code>​
 +host_conf()
 +{
 +case ${1} in
 + web*)
 +  DIR="​${DIR} /​usr/​local/​www"​
 +  HOSTGROUP="​web freebsd denmark"​
 + ;;
 +esac
 +}
 +</​code>​
 +
 +Furthermore the system looks for exclude files named: ''​exclude.default exclude.servername exclude.hostgroup''​
 +
 +using the above example and a hostname of ''​web01.example.org'',​ the following files would be included (if they exist):
 +
 +<​code>​
 +exclude.default
 +exclude.web01.example.org
 +exclude.web
 +exclude.freebsd
 +exclude.denmark
 +</​code>​
 +
 +note: if you specify DEFAULT_EXCLUDE=0 for a host, ''​exclude.default''​ will not be loaded.
 +
 +These files need to hold regex or fullname of files to exclude
 +example:
 +<​code>​
 +*.zip
 +*.t[gb]z
 +*.flv
 +</​code>​
 +
 +or look at my example files: hostconf.sh exclude.default exclude.web exclude.mysql
 +Hint: you can use zfs (or another file system with compression enabled) to have your easily compressed files etc compressed on-the-fly
 +
 +===== Syntax =====
 +
 +<​code>​
 +$path/​backup.sh host1 host2 host3
 +</​code>​
 +
 +===== Download =====
 +
 +Latest version 1.1 {{files:​backup:​backup.sh}}
 +
 +===== Changelog =====
 +=== 1.1 ===
 +       o Initial public release
 +       o Hostgroup capability added
 +=== 1.0 === 
 +       o unreleased initial version