LestatIscariot
Aktives Mitglied
- Dabei seit
- 30.12.2007
- Beiträge
- 139
- Reaktionspunkte
- 11
Vielen Dank für die Hilfe =) jetzt funktioniert es. Aber theoretisch würde es auch nichts machen wenn ich das Skript einfach in /usr/bin gelassen hätte oder?
Folgen Sie dem Video unten, um zu sehen, wie Sie unsere Website als Icon auf Ihrem Homescreen erstellen.
Anmerkung: This feature may not be available in some browsers.
sudo ./backup_home
Last login: Sat Mar 1 17:32:37 on ttyp1
Welcome to Darwin!
vincent-kemmes-computer:~ vincentkemme$ cd Desktop
vincent-kemmes-computer:~/Desktop vincentkemme$ chmod +x backup_home
vincent-kemmes-computer:~/Desktop vincentkemme$ sudo ./backup_home
Password:
[B]./backup_home: line 8: </Volumes/Backup/vincentkemme>/backup.log: No such file or directory
./backup_home: line 9: </Volumes/Backup/vincentkemme>/backup.log: No such file or directory
./backup_home: line 12: </Volumes/Backup/vincentkemme>/protokoll.log: No such file or directory
./backup_home: line 15: </Volumes/Backup/vincentkemme>/backup.log: No such file or directory
./backup_home: line 16: </Volumes/Backup/vincentkemme>/backup.log: No such file or directory
./backup_home: line 17: </Volumes/Backup/vincentkemme>/backup.log: No such file or directory
vincent-kemmes-computer:~/Desktop vincentkemme$ [/B]
Last login: Sat Jul 19 23:01:14 on console
sudo ./backup
Welcome to Darwin!
ibook:~ Mauki$ sudo ./backup
Password:
sudo: ./backup: command not found
ibook:~ Mauki$ cd Desktop
ibook:~/Desktop Mauki$ sudo ./backup
#!/bin/sh
/usr/bin/rsync -avE --delete --exclude=.Spotlight-V100 /Volumes/HD1/Daten/ /Volumes/HD2/Backup/Backup_0000-00-00/
cd /Volumes/HD2/Backup/Backup_0000-00-00 && find . -print | cpio -dpl ../"Backup_`date +%Y-%m-%d`"
Wer zu faul ist die Anleitung zu lesen hat halt Pech gehabt.Geht das auch ohne irgendwelche manpages lesen zu müsesn. Bin kein Konsolenmensch, brauche ein leicht verständliche Antwort auf deutsch!
#! /bin/sh
# --------------- Config ---------------------------
# 1) Set Directories to be backuped.
# Directories have to be placed in the file "backup_path"
# in the same directory in the following form:
# source_dir;target_dir
# make sure the files uses unix-style page breaks and UTF-8 encoding
# yes, there is a --files-from=FILE option, but hey....
# 2) Number of versions to be saved (eg 5; the minimum is 2):
c=5
# 3) condition for updates - backup every x days (eg 7=once a week
# (0=no condition, script has be be run manually or via cron)
# Set this to 0, if script is scheduled via cron
# Be aware that this function can and will confuse the update rhythm.
# Please use with caution. If unsure use cond=0
typeset -i cond # variable initialization to integer
cond=7
# 4) default file, to hold the paths to be backuped
backup_file="backup_path"
# 5) excludes file
# this contains a wildcard pattern per line of files to exclude
EXCLUDES=excludes
# 6) rsync options line
#use this line for productive run
OPTS="-avE"
#use this line for testing purpose
#OPTS="-navE"
# 7) Name and path of the global Logfile
LOGFILE="$HOME/Library/Logs/backup.log"
# 8) E-Mail adress to send status mail after backup
YOUR_MAIL="bateman23@localhost"
# 9) Path, where days-between.sh can be found
# This should be the same as the current script
helper_path="$HOME/Dropbox/Backup/"
# --------------- Check command line parameter --------------
forced_update=0 # boolean to check whether backup is forced
while getopts "hfm:" opt; do
case $opt in
f) forced_update=1
;;
m) backup_file=$OPTARG
;;
h) echo "run an incremental backup via rsync"
echo 'usage: backup_script [-f] [-m filename]'
echo "Options: -f force backup"
echo " -h print this help and exit"
echo " -m specify filename"
exit 0 ;;
esac
done
# --------------- Variable init -----------------------------
# directories to be backuped in an array
declare -a source_path
declare -a target_path
IFS=$'\n' ## not necessary if the elements have no whitespace
source_path=( $( awk -F';' '{print $1}' $backup_file) )
target_path=( $( awk -F';' '{print $2}' $backup_file) )
# general variables
i=0 # counter to loop over all directories to be backuped
ct_error=0 # counter for the errors which occured during backup
ext_file=0 # use external file as command line argument?
last_status="ok" # status of last backup - NOT IN USE
# integer values for date calculaion
typeset -i date_diff # difference of curr date to date of last backup
# --------------- Check result of last backup --------------
# see whether last backup has been completed correctly. For that check the last line, which should begin with "Backup finished at:" if that's the case, backup is ok, if not: last backup has not been completed.
# This does NOT check, if any directory had been resulting in ERR, but only whether the script ran completely the last time.
# only check if logfile exists
if [ -e $LOGFILE ]; then
last_backup=$( tail -1 $LOGFILE )
last_backup=${last_backup:0:19}
if [ "$last_backup" == "Backup finished at:" ]; then
# last backup ok - continue
/bin/echo "Last backup ok" >> $LOGFILE
last_status="ok"
else
# last backup not completed - Error
if [ $forced_update -eq 0 ]; then
growlnotify -m "Previous backup not completed. Please check log and use option -f to force backup if you wish."
start_date=$( /bin/date )
/bin/echo "--------------------------------------" >> $LOGFILE
/bin/echo "Pre-Check at $start_date : Last backup not completed correctly. Please use the command line option -f to force a backup if you know what you're doing." >> $LOGFILE
last_status="nok"
exit
else
# last backup not ok, but forced update
/bin/echo "Last backup NOT ok, but forced update"
last_status="nok"
fi
fi
fi
# --------------- Initial Checks ---------------------------
# Start logging
start_date=$( /bin/date )
/bin/echo "--------------------------------------" >> $LOGFILE
/bin/echo "Backup started at: $start_date" >> $LOGFILE
# which input file is being used
/bin/echo "Used Input-File: " $backup_file >> $LOGFILE
# Number of directories to be backuped
/bin/echo "Number of Folders to be backuped: " ${#source_path[@]} >> $LOGFILE
# check if source and target array have the same length - if not exit script
if [ ${#source_path[@]} -ne ${#target_path[@]} ]; then
/bin/echo "Source and Target not specified correctly. Aborting... Please check file $backup_file" >> $LOGFILE
exit
fi
# echo, if forced backup or condition=0
if [ $forced_update -eq 1 ]; then
/bin/echo "Condition set to f: Forced Backup" >> $LOGFILE
else
if [ $cond -eq 0 ]; then
/bin/echo "Condition set to 0: running script" >> $LOGFILE
fi
fi
# loop over all directories to be backuped
for a in ${source_path[@]}
do
b=${target_path[${i}]}
# *** debugging ***
#i=$i+1
#done
#exit
# Check whether target-directory exists and Volume is mounted
if [ -d "$b" ]; then
# create if backup path doesn't exist
e=$c
while [ $e -gt 0 ]; do
let e=e-1
if [ -d $b/backup.$e ]; then
echo "" > /dev/null
else
mkdir $b/backup.$e
fi
done
# Logging for each single path
start_date=$( /bin/date )
touch $b/backup.log
/bin/echo "---------------------------" >> $b/backup.log
/bin/echo "Backup started at: $start_date" >> $b/backup.log
# ------------- check backup condition ----------
# check, whether backup has to be done. Difference between current date and date of last backup
# has to be same or bigger than condition, which is set in variable $cond
# for this read the date of the last backup (in file $b/backup.0/datum).
# if command line parameter -f is set, an exceptional backup is forced
if [ $forced_update -eq 0 ]; then
# no forced update so check further condition
if [ $cond -eq 0 ]; then # run script
/bin/echo "Condition set to 0: running script" >> $b/backup.log
do_backup=1
else # calculate time diff and compare to cond
# getting date of last backup from $b/backup.0/datum; 1st line
# (format: 08/08/2008 - 19:32:04)
# check if file exists; if it doesn't: seems to be the first run
if [ -e $b/backup.0/datum ]; then
# read file
past_date=$( awk 'FNR == 1' $b/backup.0/datum )
past_date=${past_date:0:10}
# getting current date (format: 08/30/2008)
curr_date=$( /bin/date "+%m/%d/%Y" )
# calculating dime difference of these two dates
date_diff=$( "$helper_path"days-between.sh $past_date $curr_date )
date_diff=$((date_diff))
else
# to force backup on the first run (datum file doesn't exist)
date_diff=$cond
fi
# compare it to the condition stored in variable cond
if [ $date_diff -lt $cond ]; then
# don't run the script as number of days until
# next backup not yet reached
/bin/echo "Only $date_diff days since last backup. According to your condition no new backup needed for $b." | tee -a $b/backup.log | tee -a $LOGFILE
do_backup=0
else
/bin/echo " Condition met. $date_diff days since last backup." | tee -a $b/backup.log | tee -a $LOGFILE
do_backup=1
fi
fi
else # forced update
/bin/echo "Condition set to f: Forced Backup" >> $b/backup.log
do_backup=1
fi
# run backup or not
if [ $do_backup -eq 1 ]; then
# --------------- rotate Backup directory ----------------
let c=c-1
d=$c
rm -rf $b/backup.$c
while [ $c -gt 1 ]; do
let d=$c
let c=c-1
mv $b/backup.$c $b/backup.$d
done
let d=d-1
let c=c-1
cd $b/backup.$c && find . -print | cpio -dpl ../backup.$d
# --------------- run rsync ------------------------------
/usr/bin/rsync "$OPTS" "$a/" "$b/backup.0/" 2>> $b/backup.log
# output return code
rc=$?
# ---- Feedback/Log for single directory ------------------
# check return code
if [ $rc -eq 0 ]; then
/bin/echo "SUC - Backup of $a terminated with RC $rc." | tee -a $b/backup.log | tee -a $LOGFILE
else
/bin/echo "ERR - Backup of $a terminated with RC $rc." | tee -a $b/backup.log | tee -a $LOGFILE
ct_error=$ct_error+1
fi
fin_date=$( /bin/date )
/bin/echo "Backup finished at: $fin_date" >> $b/backup.log
# Datum von backup.0 in eine Datei sichern
/bin/date "+%m/%d/%Y - %H:%M:%S" > $b/backup.0/datum
else # [ $do_backup -ne 1]
# don't run backup
/bin/echo
fi
# ---------------- else: Error -------------
else
/bin/echo "ERR - Backup of $a NOT completed. Target not reachable" >> $LOGFILE
growlnotify -n "Backup" -m "Backup of $a terminated with error!"
ct_error=ct_error+1
fi
# --------------- Resert Variables and Loop ------------------
# End of Loop
# reset c
c=5
# for accessing the target array
i=$i+1
done
# ----- Overall Feedback/Log ----------------
fin_date=$( /bin/date )
/bin/echo "Backup finished at: $fin_date" >> $LOGFILE
if [ $ct_error == 0 ]; then
growlnotify -m "Backup completed!"
#mail -s "Backup completed" $YOUR_MAIL < mail_succ.txt
else
growlnotify -m "Backup finished with errors. Please check log."
#mail -s "Backup failed" $YOUR_MAIL < mail_err.txt
fi
rsync -vaP /Volumes/Download/SCHLECKER/ /Users/maNuel/Desktop/SCHLECKER/
...
Pictures/BilderDatenbank/2007/12_Dezember/Schnee/._IMG_3444.JPG
Pictures/BilderDatenbank/2007/12_Dezember/Schnee/._IMG_3445.JPG
Pictures/BilderDatenbank/2007/12_Dezember/Schnee/._IMG_3446.JPG
Pictures/BilderDatenbank/2007/12_Dezember/Schnee/._IMG_3447.JPG
Pictures/BilderDatenbank/2007/12_Dezember/Schnee/._IMG_3448.JPG
Pictures/BilderDatenbank/2007/12_Dezember/Schnee/._IMG_3449.JPG
Pictures/BilderDatenbank/2007/12_Dezember/Schnee/._IMG_3450.JPG
...
Library/Cookies/
Library/Cookies/Cookies.plist
Library/Mail/
Library/Mail/Envelope Index
Library/Mail/*****/INBOX.mbox/Messages/51945.emlx
Library/Safari/
Library/Safari/History.plist
Library/Safari/HistoryIndex.sk
Library/Safari/LastSession.plist
Library/Safari/WebpageIcons.db
Music/iTunes/
Music/iTunes/iTunes Library
Music/iTunes/iTunes Music Library.xml
Programme/
Programme/Backup/
Programme/Backup/mybackup.command
Programme/Backup/rsync_backup.log
Programme/Backup/rsync_protokoll.log
rsync: mknod "/Volumes/Backup/private/var/launchd/0/sock" failed: Invalid argument (22)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-24.1/rsync/main.c(717)
4314.56 real 673.37 user 1094.63 sys
Hallo sheep,
ich habe einige Fragen zu folgender Zeile unter "Punkt 4. Das komplette System (bootbar)"
Dann die Datei auf dem Desktop unter dem Namen "backup_excludes.txt"* speichern. Diese Ausnahmeliste wird später dafür sorgen, dass der Sicherungsvorgang reibungslos durchlaufen kann.
*ACHTUNG: TextEdit versieht standardmässig alle Dateien mit dem Suffix .txt, was hier unerwünscht ist. Daher sollte man im Speichern-Dialog den Haken bei ".txt verwenden, falls kein Suffix angegeben ist" entfernen.
ins terminal eingebe und wenn ichs ohne .txt speichere, findet das terminal die datei nich? Es kommt quasi nich ma dazu, dass ich nach dem Passwort gefragt werde.cd Desktop
chmod +x backup_system
sudo mv backup_excludes.txt /
aber leider verschwindet die 2. Textdatei sofort vom desktop (mit geschriebenen .txt), sobald ich den command ins terminal eingebe und wenn ichs ohne .txt speichere, findet das terminal die datei nich? Es kommt quasi nich ma dazu, dass ich nach dem Passwort gefragt werde.
Hat jemand ne idee?
gibts auch noch nen anderen Weg, z.B. über ein Programm?
"sudo mv backup_excludes.txt /" (...) danach is es wech und nix passiert weiter und da sollte doch ein backup losgehen, oda?