Hallo Leute, ich habe folgendes Backupscript:
Dieses Scripf funktioniert als root in der Konsole ausgeführt wunderbar. Lasse ich es aber via Cron laufen, erhalte ich folgende Systemmail:
Kann mir jemand einen Tipp geben, wie ich das hingebogen bekomme?
Warum kann ich das Script richtig ausführen, wenn ich es als root auf der Konsole starte, aber nicht per cron (welcher ja auch eigentlich unter dem User root läuft?
Code:
#!/bin/bash
# the name of this stuff
PROGNAME=`basename $0`
# directory to save backupfile
DAR_VERZ="/home/samuel"
function error_exit
{
echo "$1" 1>&2
exit 1
}
###############################################################################
# Do a full Backup
###############################################################################
function doFullBackup
{
# Volles Backup
dar -v -c "$DAR_VERZ/BACKUP/home_$(date +%y%m%d_%H%M)" \
-R "$DAR_VERZ/" \
-s 4613734400 -p -D -y -m 256 \
-Z "*.avi" -Z "*.bz2" -Z "*.gif" -Z "*.gz" -Z "*.jpg" \
-Z "*.mov" -Z "*.mpg" -Z "*.pbm" -Z "*.pdf" -Z "*.png" \
-Z "*.pnm" -Z "*.Z" -Z "*.zip" \
-P "BACKUP" \
-P "downloads" \
-P ".kde/cache-desktop" \
-P ".kde/cache-linux" \
-P "MedienDatenbank" \
-P ".wine/" \
-P ".thumbnails/" \
-P ".googleearth/" \
-P "google-earth/" \
-P "+++tmp+++/" \
-P "wink/" \
-P "winetools/" \
-P "eclipseWorkspace/" \
-P ".ies4linux/" \
-P ".macromedia" \
-P ".netbeans" \
-P ".local/share/Trash"
}
###############################################################################
# Do an inkremental Backup
###############################################################################
function doInkBackup
{
# Inkrementelles Backup
dar -v -c "$DAR_VERZ/BACKUP/home_$(date +%y%m%d_%H%M)" \
-R "$DAR_VERZ/" \
-A "$DAR_VERZ/BACKUP/home_$LASTBACKUP" \
-s 734003200 -p -D -y -m 256 \
-Z "*.avi" -Z "*.bz2" -Z "*.gif" -Z "*.gz" -Z "*.jpg" \
-Z "*.mov" -Z "*.mpg" -Z "*.pbm" -Z "*.pdf" -Z "*.png" \
-Z "*.pnm" -Z "*.Z" -Z "*.zip" \
-P "BACKUP" \
-P "downloads" \
-P ".kde/cache-desktop" \
-P ".kde/cache-linux" \
-P "MedienDatenbank" \
-P ".wine/" \
-P ".thumbnails/" \
-P ".googleearth/" \
-P "google-earth/" \
-P "+++tmp+++/" \
-P "wink/" \
-P "winetools/" \
-P "eclipseWorkspace/" \
-P ".ies4linux/" \
-P ".macromedia" \
-P ".netbeans" \
-P ".local/share/Trash"
}
###############################################################################
# get Timestamp of the last Backup, and use it for new Filename
###############################################################################
function lastBackup
{
# Auslesen der letzten Zeile (lastBackup.inf), wenn incremental Backup ausgeführt werden soll.
if [ -s "./lastBackup.inf" ]
then
LASTBACKUP=`tail -1 ./lastBackup.inf`
fi
# Den aktuellen Zeitpunkt festhalten, um incremental-Backups erzeugen zu können
NEWBACKUP=$(date +%y%m%d_%H%M)
echo $NEWBACKUP >> ./lastBackup.inf
}
if [ "$1" == "-i" ]
then TYP="Inkrementelles "
else TYP="Full "
fi
###############################################################################
# create list of actual installed packages
###############################################################################
function createRPMList ()
{
echo "Erstelle Liste der installierten RPMs"
RPM=$DAR_VERZ/RPMListe_$(date +%y%m%d)
/bin/rpm -qa | /usr/bin/sort >> $RPM
}
###############################################################################
# Main-Section of the Programm
###############################################################################
kdialog --yesno "$TYP Backup von '/home/samuel/' jetzt ausführen?"
createRPMList
if [ $? = 1 ]
then error_exit "Das Programm wurde beendet."
else
# Wenn -i gesetzt ist, mach das Backup inkrementell, sonst full-Backup
if [ "$1" == "-i" ]
then
lastBackup;
if [ $LASTBACKUP ]
then
doInkBackup
kdialog --yesno "Inkrementelles Backup wurde fertiggestellt. Bitte lege eine CD in den Brenner um das Backup home_$NEWBACKUP zu sichern.\nMöchten Sie das Brennprogramm jetzt starten?"
# Öffne auf Wunsch direkt das Brennprogramm und füge die aktuelle Datei der CD hinzu
if [ $? = 0 ]; then
`/opt/kde3/bin/k3b --nosplash --datacd /home/samuel/BACKUP/home_$NEWBACKUP.1.dar /home/samuel/BACKUP/lastBackup.inf $RPM`
fi
else
kdialog --error "Keine Vollsicherung in lastBackup.inf verzeichnet, daher kein inkrementelles Backup möglich!"
error_exit
fi
else
doFullBackup
kdialog --yesno "Full Backup wurde fertiggestellt. Bitte lege eine DVD in den Brenner um das Backup home_$NEWBACKUP zu sichern.\nMöchten Sie das Brennprogramm jetzt starten?"
# Öffne auf Wunsch direkt das Brennprogramm und füge die aktuelle Datei der CD hinzu
if [ $? = 0 ]; then
`/opt/kde3/bin/k3b --nosplash --datadvd /home/samuel/BACKUP/home_$NEWBACKUP.1.dar /home/samuel/BACKUP/lastBackup.inf $RPM /home/samuel/BACKUP/home.sh`
fi
fi
fi
exit 0
Dieses Scripf funktioniert als root in der Konsole ausgeführt wunderbar. Lasse ich es aber via Cron laufen, erhalte ich folgende Systemmail:
/home/samuel/BACKUP/home.sh: line 119: kdialog: command not found
Erstelle Liste der installierten RPMs
error: rpmdbNextIterator: skipping h# 3597 Header SHA1 digest: BAD Expected(36cf4e0706e620d0d0d1b5b79d978e6706168aeb) != (e9027be0aea512b0d899b91f7bd0a3030283356d)
No terminal found for user interaction. All questions will be assumed a negative answer (less destructive choice), which most of the time will abort the program.
Aborting program. User refused to continue while asking: /home/samuel/BACKUP/home_080519_1100.1.dar is required for further operation, please provide the file.
/home/samuel/BACKUP/home.sh: line 133: kdialog: command not found
Kann mir jemand einen Tipp geben, wie ich das hingebogen bekomme?
Warum kann ich das Script richtig ausführen, wenn ich es als root auf der Konsole starte, aber nicht per cron (welcher ja auch eigentlich unter dem User root läuft?