Fonction d'historisation de dossiers
Le 5 août 2008, à 15:59 par Ulhume...
Pour mémoire, une petite fonction en Bash qui permet la rotation d'une série de dossiers d'historisation rendu obsolète (du moins j'espère) par rdiff-backup :
# opère une rotation des dossiers historisés
function rotate_storage
{
trace
"Backup Storage Rotation for $storage_path"
# transfert de l'ancien "current" dans "history"
currentDate=$
(stat $storage_path -c
"%Z")
currentDate=$
(date -d
"1970-01-01 ${currentDate}sec GMT" +
"%y-%m-%d_%H-%M-%S")
history_path=$storage_path/..
/history
mkdir -p
$history_path
cp -al
"$storage_path/." $history_path/$currentDate
cd $history_path
# réduction du nombre de dossier au nombre maximum définit par défaut
local iFolder=0
local folder
{
local folder
find . -maxdepth
1 -type d
| grep "./" | while read folder;
do
stat $folder -c
"%Z %n"
done | sort -rn -k1 -t
' ' | awk '{print $2}'
} |
while read folder ;
do
if [ $iFolder -gt
$BACKUP_ROTATION_MAX_FOLDERS ] ;
then
trace
"Deleting too old history folder : $folder"
rm -rf
"$folder"
fi
let iFolder=$iFolder+1
done
cd ..
# finalisation
touch $history_path
}
Poster un nouveau commentaire