Ceci est une ancienne révision du document !
dar est un utilitaire sous linux permettant de réaliser des sauvegardes simple avec quelques fonctions avancées comme :
Cette page décrit comment l'utiliser ponctuellement ou de manière automatisée.
#!/bin/sh # Dar backup script # Matthieu Bouthors # http://www.bouthors.fr # licence GPLv2 # location of files config_dir=/home/scripts # temporary file run_file=archive_gandalf_running # dar options (DCF format) dar_options=gandalf.dcf # file that save the last full backup last_backup_file=last_dar # destination folder archive_dir=/data/backup case "$1" in full) if [ -e "$config_dir/$run_file" ] then echo archive already running exit 1 fi touch "$config_dir/$run_file" archive_file="full_`date +%Y%m%d_%H%M%S`" echo $archive_file /usr/bin/dar -c $archive_dir/$archive_file -B $config_dir/$dar_options if [ $? -eq 0 ] then echo "$archive_dir/$archive_file" > $config_dir/$last_backup_file rm -f "$config_dir/$run_file" exit 0 fi rm -f "$config_dir/$run_file" exit $? ;; inc) if [ ! -e "$config_dir/$last_backup_file" ] then echo no previous dar exit 1 fi old_dar=`cat $config_dir/$last_backup_file` echo reference dar : $old_dar if [ ! -e "$old_dar.1.dar" ] then echo previous dar not found exit 1 fi if [ -e "$config_dir/$run_file" ] then echo archive already running exit 1 fi touch "$config_dir/$run_file" archive_file="inc_`date +%Y%m%d_%H%M%S`" echo $archive_file /usr/bin/dar -c $archive_dir/$archive_file -A $old_dar -B $config_dir/$dar_options if [ $? -eq 0 ] then rm -f "$config_dir/$run_file" exit 0 fi rm -f "$config_dir/$run_file" exit $? ;; kill) killall dar rm -f "$config_dir/$run_file" exit 0 ;; *) echo "option : full, inc" exit 1 esac exit 0
Voici un script permettant de supprimer les sauvegardes trop vielles
#!/bin/sh # Dar cleanup script # Matthieu Bouthors # http://www.bouthors.fr # licence GPLv2 #folder to watch : watch_folder=/data/backup/ # delete inc files older than inc_keep days : inc_keep=60 # delete full files older than full_keep days : full_keep=180 now=`date +%s` limit_keep=$(($now-($inc_keep*86400))) for filename in `ls $watch_folder/inc*.dar` do find_date_text=`expr match $filename '.*/inc_\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)_'` date_file=`date -d $find_date_text +%s` if [ $date_file -lt $limit_keep ] then /bin/rm -vf $filename fi done limit_keep=$(($now-($full_keep*86400))) for filename in `ls $watch_folder/full*.dar` do find_date_text=`expr match $filename '.*/full_\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)_'` date_file=`date -d $find_date_text +%s` if [ $date_file -lt $limit_keep ] then /bin/rm -vf $filename fi done