937 shaares
44 private links
44 private links
Script Bash bien documenté.
echo "Changing path.."
cd "/sauvegardes/"
if [ -f 'archivage.lock.txt' ]; then
echo "Lockfile found, exit"
exit
fi
echo "Setting lockfile"
touch 'archivage.lock.txt'
filename=$(date +%Y-%m-%d)
echo "Finding oldest archive"
oldest=$(ls -tr1 "archives/" | head -1)
echo "Oldest is $oldest, moving to $filename"
mv "archives/$oldest" "archives/$filename"
echo "Now doing rsync archive"
rsync -a --progress --delete-before --no-inc-recursive "incoming/" "archives/$filename/"
touch "archives/$filename/"
echo "Finished, removing lock and exit"
rm 'archivage.lock.txt'