Le jeu. 1 oct. 2020 à 11:47, felix <[email protected]> a écrit : > (Nota: je préfère ``tirer les données depuis la machine de backups'', > plutôt que d'avoir un accès à la machine de backups depuis une > machine en production)
Bonjour à tous Je rebondis sur cette remarque pertinente de Félix. Depuis que l'incitation à des économies d'énergie nous fait éteindre les machines quand on ne les utilise pas (... même le standby consomme beaucoup... j'ai mesuré), le backup en "pull" pose un problème parce que lorsque le backup est initié sur le serveur, la machine à backuper peut être éteinte. J'ai trouvé un joli script (il n'est pas de moi) que le crontab du serveur "backup" pourra appeler chaque heure et qui teste si la machine qu'il faut backuper est allumée. Si oui et que le dernier backup date de plus que x heures, le backup est initié. Le script est écrit pour rsnapshot, mais on peut évidemment adapter. J'ai pensé que ça pourrait être utile à certains. Pierre-Olivier Maitre Réf: https://bbs.archlinux.org/viewtopic.php?id=120127 J'ai adapté un peu. Exemple: on veut faire le backup de l'ordinateur "station0": #!/bin/bash if ! /bin/ping -c 1 192.168.1.116 &> /dev/null; then echo "station0 not available"; exit 1; fi # pour remote host: if ! /usr/bin/nping --tcp -p (port) -c1 remotehost.net &> /dev/null; then echo.... DATEDIR=/var/lib/rsnap_station0 LASTMONTHLY=$(stat -c %X $DATEDIR/monthly-station0) LASTWEEKLY=$(stat -c %X $DATEDIR/weekly-station0) LASTDAILY=$(stat -c %X $DATEDIR/daily-station0) NOW=$(date +%s) MONTH=2415600 # 27 days, 23 hours WEEK=601200 # 6 days, 23 hours DAY=82800 # 23 hours SUCCESS=0 if [[ "$(($NOW-$LASTMONTHLY))" -gt "$MONTH" ]]; then echo "Starting monthly snapshot" > /var/log/rsnapshot.station0.last /usr/bin/rsnapshot -v -c /etc/rsnapshot.station0.conf monthly 2>&1 >> /var/log/rsnapshot.station0.last || SUCCESS="1" if [[ $SUCCESS == "0" ]]; then echo "Monthly snapshot successful" >> /var/log/rsnapshot.station0.last touch $DATEDIR/monthly-station0 else echo "Error(s) with monthly snapshot" >> /var/log/rsnapshot.station0.last fi fi SUCCESS=0 if [[ "$(($NOW-$LASTWEEKLY))" -gt "$WEEK" ]]; then echo "Starting weekly snapshot" > /var/log/rsnapshot.station0.last /usr/bin/rsnapshot -v -c /etc/rsnapshot.station0.conf weekly 2>&1 >> /var/log/rsnapshot.station0.last || SUCCESS="1" if [[ $SUCCESS == "0" ]]; then echo "Weekly snapshot successful" >> /var/log/rsnapshot.station0.last touch $DATEDIR/weekly-station0 else echo "Error(s) with weekly snapshot" >> /var/log/rsnapshot.station0.last fi fi SUCCESS=0 if [[ "$(($NOW-$LASTDAILY))" -gt "$DAY" || "$1" == "-f" ]]; then echo "Starting daily snapshot" > /var/log/rsnapshot.station0.last /usr/bin/rsnapshot -v -c /etc/rsnapshot.station0.conf daily 2>&1 >> /var/log/rsnapshot.station0.last || SUCCESS="1" # /usr/bin/rsnapshot -c /etc/rsnapshot.station0.conf daily 2>&1 |/usr/local/bin/rsnapreport.pl | mail -s "laptop daily" [email protected] || SUCCESS="1" if [[ $SUCCESS == "0" ]]; then echo "Daily snapshot successful" >> /var/log/rsnapshot.station0.last touch $DATEDIR/daily-station0 else echo "Error(s) with daily snapshot" >> /var/log/rsnapshot.station0.last fi fi _______________________________________________ gull mailing list [email protected] https://forum.linux-gull.ch/mailman/listinfo/gull
