
Guten Tag
Ich verwende dieses Skript, um meinen Heim-PC auf einem Remote-PC zu sichern
#!/bin/bash
#Todays date in ISO-8601 format:
DAY0=`date -I`
#Yesterdays date in ISO-8601 format:
DAY1=`date -I -d "1 day ago"`
#The source directory:
SRC="/home/honza/Downloads/"
#The target directory:
TRG="[email protected]:/media/zaloha/$DAY0"
#The link destination directory:
LNK="[email protected]:/media/zaloha/$DAY1"
#The rsync options:
OPT="-avh --delete --link-dest=$LNK
#Execute the backup
rsync $OPT $SRC $TRG
#3 days ago in ISO-8601 format
DAY3=`date -I -d "3 days ago"`
#Delete the backup from 3 days ago, if it exists
if [ -d /[email protected]:/media/zaloha/$DAY3 ]
then rm -R /[email protected]:/media/zaloha/$DAY3
fi
Ich weiß nicht, wie ich ein älteres Backup löschen kann, das älter als 3 Tage ist. Das Skript funktioniert gut, wenn ich ein Backup auf demselben PC mache, aber nicht auf einem Remote-PC.
--link-dest arg does not exist: /[email protected]:/media/zaloha/2013-03-15
und alte Backups werden nicht gelöscht.
Es funktioniert auch gut, wenn ein Skript auf dem Remote-PC ausgeführt wird. Ein SRC ist
SRC = "[email protected]:/home/hunts/Downloads"
Aber ich weiß nicht, ob es die Managementlösung ist? Danke
Antwort1
Ich glaube nicht, dass dieser Löschbefehl funktioniert. Vielleicht kannst du versuchen, die Datei mit einem direkten SSH-Befehl zu löschen, etwa:
ssh [email protected] rm -rf /media/zaloha/$DAY3
Tut mir leid, aber ich kann Ihnen nicht sagen, warum das "link-dest"-Argument nicht funktioniert.