Backupproblem mit tecback

cracksilver

cracksilver

kanotix - neewbie
Hallo

Hab hier ein kleines Script (tecback) für die Datensicherung gefunden, hab es angepasst auf meine Situation und nun kriege ich eine Fehlermeldung die ich nicht ganz verstehe. Vielleicht kennt sich damit jemand besser aus als ich. :D

Das ist das Script:

#!/bin/sh

# tecback - 01/2003 Karsten Kruse www.tecneeq.de
# $Id: tecback,v 1.4 2005/08/07 10:23:08 karsten Exp $
#
# Installation:
# 1) Leg das Script dort ab wo du viel Platz hast und mach es ausfuerbar
# mit ,,chmod 700 tecback''.
#
# 2) Weiter unten sind einige Einstellungen die du anpassen solltest:
# * holdbackup - Das Alter in Tagen des aeltesten Backups das du
# behalten willst
# * tar - Voller Pfad zu einem GNU-tar (mindestens Version
# 1.13.25)
# * basedir - Der volle Pfad in dem dieses Script liegt
# * include - Verzeichnisse die gesichert werden sollen
# * exclude - Verzeichnisse die nicht gesichert werden sollen
# * compression - Mit welchem Kompressionsprogramm soll das Backup
# komprimiert werden? bz2=bzip2 gz=gzip keine=nichts
#
# 3) Von Hand starten um sicherzustellen das alles klappt: ,,/pfad/tecback''
#
# 4) Einen Cronjob anlegen, z.b. so: 10 2 * * * nice /pfad/tecback
#

holdbackup=90
tar=/bin/tar
basedir=/media/hdd2/_backup/
include="/home/gregi"
exclude=""
compression="none"


###### DO NOT EDIT BELOW ####################################################
bomb() { echo ERROR: $1 ; exit 1 ; } # bail out

workdir=${basedir}/archive
stampfile=${workdir}/.stampfile
incrementlist=/tmp/tecback_list.$$
hostname=`hostname -s`
monthday=`date +%d`
epoch=`date +%yy%mmo%dd_%Hh%Mm%Ss`

[ -x $tar ] || bomb "$tar nicht gefunden, Pfad falsch?"
if [ ! -d $workdir ] ; then
mkdir -p $workdir || bomb "konnte $workdir nicht anlegen, keine Rechte?"
fi

for i in $include ; do
if [ -d $i ] ; then
includeline="$i $includeline"
else
echo "$i in \$include existiert nicht und wird ignoriert"
fi
done
for i in $exclude $workdir ; do
if [ -d $i ] ; then
ignoreline="--exclude=$i/* $ignoreline"
else
echo "$i in \$exclude existiert nicht und wird ignoriert"
fi
done

# kompression
case $compression in
bz2|bzip2) endung="tar.bz2"
compcom="-j"
;;
gz|gzip) endung="tar.gz"
compcom="-z"
;;
keine|none) endung="tar"
compcom=""
;;
*) bomb "$compression ist keine gueltige Auswahl fuer compression"
esac

# needed since find, even if it has not found a file, exits with 0
fullbackups=0
for i in `find $workdir -type f -name "${hostname}_full*" -print` ; do
fullbackups=1
done

# full or incremental backup?
if [ `date +%d` = 01 \
-a ! -f ${workdir}/${hostname}_full_`date +%yy%mmo%dd_`*.${endung} \
-o ! -f $stampfile \
-o $fullbackups = 0 ] ; then
kind=full
else
kind=increment
fi

# set title of backup
title=${workdir}/${hostname}_${kind}_${epoch}.${endung}

# here we do some work
if [ $kind = increment ] ; then
last_backup=`ls -l $stampfile | awk '{print $7"."$6".",$8}'`
echo "==> performing incremental backup (new files since $last_backup)"
find $includeline -type f -newer $stampfile -print > $incrementlist
$tar -c $compcom -p $ignoreline --file $title --files-from=$incrementlist \
&& touch -r $incrementlist $stampfile
rm $incrementlist
elif [ $kind = full ] ; then
echo "==> performing full backup ..."
$tar -c $compcom -p $ignoreline --file $title $includeline \
&& touch $stampfile
fi
chmod 600 $title

# delete old backups
find $workdir -type f -name "${hostname}_*" -ctime +$holdbackup -exec rm {} \;
echo "==> ... done"


So, und das ist die Fehlermeldung

gregi@KanotixBoxLeft:/media/hdd2/_backup$ tecback
==> performing full backup ...
/bin/tar: /media/hdd2/_backup//archive/localhost_full_06y02mo03d_15h56m31s.tar: Kann open nicht ausführen.: Keine Berechtigung
/bin/tar: Nicht behebbarer Fehler: Programmabbruch.
chmod: Zugriff auf »/media/hdd2/_backup//archive/localhost_full_06y02mo03d_15h56m31s.tar« nicht möglich: Datei oder Verzeichnis nicht gefunden
==> ... done
gregi@KanotixBoxLeft:/media/hdd2/_backup$
 
Wie siehts mit den Schreibrechten in "/media/hdd2/_backup//archive/" aus?

Gruss, Phorus
 
Zuletzt bearbeitet:
hab alles unter root gemacht. Schreibrechte in diesem Verzeichniss ist auf 700.

greg
 
Schreib mal vor den tar-Befehl gleich nach der Zeile

Code:
echo "==> performing full backup ..."

ein echo, also

Code:
echo $tar -c $compcom -p $ignoreline --file $title $includeline \

und poste mal die Ausgabe.

edit: Weiterhin mach mal bitte ein

Code:
touch /media/hdd2/_backup//archive/bla

und guck, ob da Fehler kommen.
 
Zuletzt bearbeitet:
Fehlermeldung:

==> performing full backup ...
/bin/tar -c -p --exclude=/media/hdd2/_backup//archive/* --file /media/hdd2/_backup//archive/localhost_full_06y02mo03d_16h48m02s.tar /home/gregi
chmod: Zugriff auf »/media/hdd2/_backup//archive/localhost_full_06y02mo03d_16h48m02s.tar« nicht möglich: Datei oder Verzeichnis nicht gefunden
==> ... done

touch ist i. o. keine Ausgabe

gruss greg
 
der Fehler ist doch offensichtlich :).
 
avaurus schrieb:
der Fehler ist doch offensichtlich :).
klar kann er /media/hdd2/_backup//archive/localhost_full_06y02mo03d_16h48m02s.tar nicht öffnen und nicht finden weil er ja eigentlich localhost_full_06y02mo03d_16h48m02s.tar in ../archive anlegen sollte
 
Also hab das ganze mal in den Pfadangaben abgeändert, er amcht jetzt auch ein Backup, komischerweise ist das aber nur etwa 200kb gross obwohl da eigentlich mehrere gigas liegen.

Hier nochmals die neue version:
Code:
#!/bin/sh

#  tecback - 01/2003 Karsten Kruse www.tecneeq.de
#  $Id: tecback,v 1.4 2005/08/07 10:23:08 karsten Exp $
#
#  Installation:
#   1) Leg das Script dort ab wo du viel Platz hast und mach es ausfuerbar
#      mit ,,chmod 700 tecback''.
#
#   2) Weiter unten sind einige Einstellungen die du anpassen solltest:
#        * holdbackup  - Das Alter in Tagen des aeltesten Backups das du
#                        behalten willst
#        * tar         - Voller Pfad zu einem GNU-tar (mindestens Version
#                        1.13.25)
#        * basedir     - Der volle Pfad in dem dieses Script liegt
#        * include     - Verzeichnisse die gesichert werden sollen
#        * exclude     - Verzeichnisse die nicht gesichert werden sollen
#        * compression - Mit welchem Kompressionsprogramm soll das Backup
#                        komprimiert werden? bz2=bzip2 gz=gzip keine=nichts
#
#   3) Von Hand starten um sicherzustellen das alles klappt: ,,/pfad/tecback''
#
#   4) Einen Cronjob anlegen, z.b. so: 10 2 * * * nice /pfad/tecback
#

holdbackup=90
tar=/bin/tar
basedir=/media/hdd2/_backup/
include=/home/gregi
exclude= 
compression=none


###### DO NOT EDIT BELOW ####################################################
bomb() { echo ERROR: $1 ; exit 1 ; }                 # bail out

workdir=${basedir}/archive
stampfile=${workdir}/.stampfile
incrementlist=/tmp/tecback_list.$$
hostname=`hostname -s`
monthday=`date +%d`
epoch=`date +%yy%mmo%dd_%Hh%Mm%Ss`

[ -x $tar ] || bomb "$tar nicht gefunden, Pfad falsch?"
if [ ! -d $workdir ] ; then
  mkdir -p $workdir || bomb "konnte $workdir nicht anlegen, keine Rechte?"
fi

for i in $include ; do
  if [ -d $i ] ; then
    includeline="$i $includeline"
  else
    echo "$i in \$include existiert nicht und wird ignoriert"
  fi
done
for i in $exclude $workdir ; do 
  if [ -d $i ] ; then
    ignoreline="--exclude=$i/* $ignoreline"
  else
    echo "$i in \$exclude existiert nicht und wird ignoriert"
  fi
done

# kompression
case $compression in
  bz2|bzip2)   endung="tar.bz2"
	       compcom="-j"
	       ;;
  gz|gzip)     endung="tar.gz"
	       compcom="-z"
	       ;;
  keine|none)  endung="tar"
	       compcom=""
	       ;;
  *)           bomb "$compression ist keine gueltige Auswahl fuer compression"
esac

# needed since find, even if it has not found a file, exits with 0
fullbackups=0
for i in `find $workdir -type f -name "${hostname}_full*" -print` ; do
  fullbackups=1
done

# full or incremental backup?
if [ `date +%d` = 01 \
      -a ! -f ${workdir}/${hostname}_full_`date +%yy%mmo%dd_`*.${endung} \
      -o ! -f $stampfile \
      -o $fullbackups = 0 ] ; then
  kind=full
else
  kind=increment
fi

# set title of backup
title=${workdir}/${hostname}_${kind}_${epoch}.${endung}

# here we do some work
if [ $kind = increment ] ; then
  last_backup=`ls -l $stampfile | awk '{print $7"."$6".",$8}'`
  echo "==> performing incremental backup (new files since $last_backup)"
  find $includeline -type f -newer $stampfile -print > $incrementlist
  $tar -c $compcom -p $ignoreline --file $title --files-from=$incrementlist \
    && touch -r $incrementlist $stampfile
  rm $incrementlist
elif [ $kind = full ] ; then
  echo "==> performing full backup ..."
  $tar -c $compcom -p $ignoreline --file $title $includeline \
    && touch $stampfile
fi
chmod 600 $title

# delete old backups
find $workdir -type f -name "${hostname}_*" -ctime +$holdbackup -exec rm {} \;
echo "==> ... done"

Ich starte das script:
root@KanotixBoxLeft:/media/hdd2/_backup# . tecback
==> performing incremental backup (new files since 17:06.2006-02-03. /media/hdd2/_backup//archive/.stampfile)
/bin/tar: Removing leading `/' from member names
rm: reguläre Datei »/tmp/tecback_list.22843« entfernen? y
==> ... done

so siehts nach ls -s aus:
root@KanotixBoxLeft:/media/hdd2/_backup/archive# ls -s
insgesamt 243314
0 bla 10 localhost_increment_06y02mo03d_17h06m41s.tar
192443 localhost_full_06y02mo03d_17h02m42s.tar 33944 localhost_increment_06y02mo03d_17h12m04s.tar
16917 localhost_increment_06y02mo03d_17h03m21s.tar


gruss gregi
 
hallo,
versuche es doch mal mit
basedir=/media/hdd2/_backup
nicht mit
basedir=/media/hdd2/_backup/

»/media/hdd2/_backup//archive/localhost_full_06y02mo03d_15h56m31s.tar

ich denke das da (rot) der fehler liegt.
 
Code:
[~]$ tar -cf test.tar freizeit/rtb && echo gixgax
gixgax
[~]$ tar -cf test.tar freizeit///////////rtb && echo gixgax
gixgax

:think:

edit: Der vollständigkeithalber wieder auspacken:

Code:
[test]$ tar xf test2/test3/test.tar && echo gixgax
gixgax
[test]$ tar xf test2//////////test3///////////test.tar && echo gixgax
gixgax
 
Zuletzt bearbeitet:
cracksilver schrieb:
root@KanotixBoxLeft:/media/hdd2/_backup/archive# ls -s
insgesamt 243314
0 bla 10 localhost_increment_06y02mo03d_17h06m41s.tar
192443 localhost_full_06y02mo03d_17h02m42s.tar 33944 localhost_increment_06y02mo03d_17h12m04s.tar
16917 localhost_increment_06y02mo03d_17h03m21s.tar

Nun ja, was ist denn drin in localhost_full_06y02mo03d_17h02m42s.tar ?
 
ich habe das ganze von http://www.newbie-net.de/anleitung_backup.html
da ist es wunderbar beschrieben und es lief sofort ohne probleme.

dann noch mit "crontab -e" (root) dem ganzen sagen wann und was

20 4 * * * /PFAD_ZU/tecback - täglich um 4:20uhr nen backup der geänderten daten
0 0 * * 1 rm /PFAD_ZU/archive/.stampfile - immer montag um 0:00uhr die datei .stampfile löschen. dadurch macht er um 4:20 (siehe oben) wieder ein full-backup und du hast jedem montag eine komplett sicherung.
 

Ähnliche Themen

If-Abfrage kommt nicht positiv zurück, obwohl Kriterium erfüllt

Switche abfragen über Script

Verschlüsseltes Backup-Script mit rsync

Shell Skript beschleunigen

HandbrakeCLI Shell Skript

Zurück
Oben