rsync

rsync --bwlimit=50 --progress -r -t -h -v --del -e ssh "login@host:/home/login/path" "/home/a/b/c/"
rsync -vrltD --chmod=+rwx --delete -e 'ssh -p 22422' /remote/path /local/path

Gérer la conversion de l’encodage

Il faut rajouter l’option --iconv=UTF-8-MAC,UTF-8

Script de déploiement

#!/bin/bash

option=""
branch="master"

read -p "Dry run ? [y/n] " answer
case $answer in
    [Yy]* ) option="--dry-run";;
    [Nn]* ) ;;
        * ) echo "I don't understand, bye bye ...";exit;;
esac

rsync --verbose --recursive \
    --human-readable \
    --delete --delete-after --force \
    --checksum $option -e ssh \
    --include-from=/path/to/$branch/deploy.include.txt \
    --exclude-from=/path/to/$branch/deploy.exclude.txt \
    /path/to/$branch/. \
    neolao@my-server.com:/home/project/.

Script de backup

#!/bin/bash

source=root@domain.com:
snapshotDir=/home/backup/domain.com

if [ -d $snapshotDir/weekly.4 ]
then
    rm -rf $snapshotDir/weekly.4
fi

for index in 3 2 1
do
    next=$(($index+1))

    if [ -d $snapshotDir/weekly.$index ]
    then
        mv $snapshotDir/weekly.$index $snapshotDir/weekly.$next
    fi
done

if [ -d $snapshotDir/weekly.0 ]
then
    cp -al $snapshotDir/weekly.0 $snapshotDir/weekly.1
fi

rsync -va --delete -e ssh $source/home $snapshotDir/weekly.0
# ssh root@domain.com 'mysqldump --host=localhost --user=me --password=1234 mybase > mybase.sql'

touch $snapshotDir/weekly.0

Script de backup à une date précise

#!/bin/bash

source=root@domain.com:
snapshotDir=/home/backup/domain.com
currentDate=`date +%Y-%m-%d_%H-%M-%S`

rsync -va -e ssh $source/home $snapshotDir/$currentDate

touch $snapshotDir/$currentDate

Script de backup à une date précise qui utilise les quotidiens

#!/bin/bash

source=root@domain.com:
currentDate=`date +%Y-%m-%d_%H-%M-%S`
snapshotDir=/home/backup/domain.com

if [ -d $snapshotDir/daily.0 ]
then
    cp -al $snapshotDir/daily.0 $snapshotDir/$currentDate
fi

rsync -va --delete -e ssh $source/home $snapshotDir/$currentDate

newDate=`date +%Y-%m-%d_%H-%M-%S`
mv $snapshotDir/$currentDate $snapshotDir/$newDate

touch $snapshotDir/$newDate