backup file trees in rotating archives: feedback, questions, discussions about rsback

Text archives Help


Re: [rsback] Searching for best configuration for a daily full backup on a usb-drive.


Chronological Thread 
  • From: Hans-Juergen Beie <hjb AT pollux.franken.de>
  • To: rsback AT lists.franken.de
  • Subject: Re: [rsback] Searching for best configuration for a daily full backup on a usb-drive.
  • Date: Sat, 24 May 2014 17:08:01 +0200
  • List-archive: <http://lists.franken.de/pipermail/rsback>
  • List-id: "backup file trees in rotating archives: feedback, questions, discussions about rsback" <rsback.lists.franken.de>
  • Organization: Kommunikations Franken e.V.

Christian-Josef Schrattenthaler schrieb am 22.05.14 16:02:
Hi!

Has anyone an optimal configuration for a daily full backup of a linux
server (Debian) on a local connected usb-drive?

Thanks,

Christian.

Supposed your usb drive is formated with a Linux file system and
mounted to /backup you may use rsback and something like this configuration /etc/rsback/rsback.conf:


---> cut here >------------------------------
# rsback main configuration
#
# This file is expected as /etc/rsback/rsback.conf by default.
#
# If you want to have it somewhere else, use
#
# rsback.pl -c <config-file> ...
#
# or change the path of the default configuration file
# in rsback ($rsback_conf).

#-----------------------------------------------------
#
# global parameters
#

[global]

#
# location of some commands we need
#
rsync_cmd = /usr/bin/rsync
cp_cmd = /bin/cp
mv_cmd = /bin/mv
rm_cmd = /bin/rm
mkdir_cmd = /bin/mkdir

#
# List of backup tasks
#
tasks = system-daily system-weekly

# the directory where these lock files will be created.
# Specify a directory by giving an absolute path without a
# trailing slash
#
lock_dir = /var/lock

#
# additional rsync options used in backup mode 'rsync'
#
# options used in any case are: -al --delete --delete-excluded --exclude-from=...
#
;rsync_options = -v --stats
rsync_options = -val --delete --delete-excluded --stats --numeric-ids --xattrs


#
# File patterns to exclude from backup regardless of the backup task
#
# -optional-
exclude_file = /etc/rsback/global.exclude

#
# If the current task is locked by an other task (see lock_dir above)
# then this parameter may be used to try to restart the task after some
# time of delay.
# The default delay value is 10 minutes.
#
# -optional-
if_locked_retry = 3 10m

#
# This defines how to proceed if a system command used by rsback
# fails. A value of 'no' means that subsequent tasks given on the
# command line are skipped (this is the default behavior). If this
# parameter is set to 'yes' then only the actual task is aborted but
# following tasks, given on the command line, are started as if no error
# has occurred.
#
# -optional-
if_error_continue = yes

# This example ignores rsync exit values of
# 12 (Error in rsync protocol data stream)
# 24 (Partial transfer due to vanished source files),
#
#ignore_rsync_errors = 12 24
ignore_rsync_errors = 24

#-----------------------------------------------------
#
# backup of system
#

[system-daily]

source = /
destination = /backup/system
rotate = daily 7
mode = rsync
rsync_options = -al --delete --delete-excluded --stats --numeric-ids
exclude_file = /etc/rsback/system.exclude
use_link_dest = yes
lock = system-weekly


[system-weekly]

source = /backup/system/daily.1/
destination = /backup/system
rotate = weekly 12
mode = link
lock = system-daily
---< cut here <------------------------------

/etc/rsback/global.exclude may look like....

---> cut here >------------------------------
# global.exclude
#
# global exclude patterns

# temp directories
#[Tt][Ee][Mm][Pp]/
#[Tt][Mm][Pp]/
#.[Tt][Ee][Mm][Pp]/
#.[Tt][Mm][Pp]/

# backup files
*.[Bb][Aa][Kk]
*~

# backup directories
[Ba][Aa][Cc][Kk][Uu][Pp]/

# temp. files
*.[pP][iI][dD]
*.[lL][oO][cC]
*.[lL][oO][cC][kK]
*.[lL][cC][kK]
*.[lL][kK]

# some other stuff
lost+found/
[fF][iI][fF][oO]
*.[fF][iI][fF][oO]
---< cut here <------------------------------

And /etc/rsback/system.exclude ....

---> cut here >------------------------------
# system exclude patterns

# System dirs which should be left
/cdrom/
/dev/
/media/
/lost+found/
/mnt/
/proc/
/srv/
/sys/
/tmp/

# homes and data may go into seperate backups
#/home/
#/data/

# rsback repositories
/backup/
---< cut here <------------------------------

Just a few more shell scripts to make backups on a regular basis ...

This one executes rsback with tasks system-daily or system-weekly and produces corresponding log files in /var/log/rsback.
When you let run it by cron root should receive daily mails containing an overview about the backup process.

---> cut here >------------------------------
#!/bin/sh
#
# backup of local system
#
# /etc/rsback/system.backup

HOST=`hostname`

# source to backup
SRC=system

# log directory
LOGDIR=/var/log/rsback

# rsback program and options
RSBACK_CMD=/usr/local/bin/rsback
RSBACK_OPTS="-v -c /etc/rsback/rsback.conf"

# this should be daily|weekly
WHEN=$1

DT=`date '+%Y-%m-%d %H:%M:%S'`
echo "$DT $0 host $HOST - $WHEN"
echo

case "$WHEN" in
daily|weekly)
echo "$DT ----- Starting $WHEN backup of $SRC -----"

TASK=$SRC-$WHEN
LOGFILE=$LOGDIR/$TASK.log

#
# backup the whole thing
#
echo " rsback config: $RSBACK_OPTS"
echo " rsback task : $TASK"
echo " log file : $LOGFILE"

$RSBACK_CMD $RSBACK_OPTS $TASK >>$LOGFILE
EXITCODE=$?

DT=`date '+%Y-%m-%d %H:%M:%S'`
echo "$DT ----- Finished $WHEN backup of $SRC -----"
echo
;;

*)
echo "Usage: $0 {daily|weekly}"
exit 1
;;
esac
---< cut here <------------------------------

This one triggers the daily work...

---> cut here >------------------------------
#!/bin/sh
#
# daily backup jobs
#
#
# ------------------------------------------------------

#
# System
#
/etc/rsback/system.backup daily

#
#
# Daten
#
#/etc/rsback/data.backup daily

---< cut here <------------------------------

And this one for weekly backup jobs:

---> cut here >------------------------------
#!/bin/sh
#
# weekly backup jobs
#
# ------------------------------------------------------

#
# System
#
/etc/rsback/system.backup weekly

#
# Daten
#
/etc/rsback/data.backup weekly
---< cut here <------------------------------

Place symlinks into /etc/cron.daily and /etc/cron.weekly ...

# ln -s /etc/rsback/daily.cron /etc/cron.daily/backup
# ln -s /etc/rsback/weekly.cron /etc/cron.weekly/backup

... and make sure that the log directory exists...

# mkdir /var/log/rsback

Now all should happen automatically.

But it's a good idea to test it manually before...

# /etc/rsback/daily.cron

... and to check if everything works.

If you your usb drive is usually not mounted place commands to mount and un-mount it into daily.cron and weekly.cron.

Good luck
hjb :-?





Archive powered by MHonArc 2.6.19+.

Top of page