aboutsummaryrefslogtreecommitdiffstats
path: root/backup.sh
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2014-10-05 17:12:35 +0200
committerlookshe <github@lookshe.org>2014-10-05 17:12:35 +0200
commit41995c1ef2906ccf93728fefc65fee1b29ac6404 (patch)
tree0c847478b768c33878b134ef96939003f75748d1 /backup.sh
parent230462cbce1e2ee7758e4b9224a1c83663c8b70c (diff)
added script for databases
some little fixes in backup.sh
Diffstat (limited to 'backup.sh')
-rwxr-xr-xbackup.sh13
1 files changed, 7 insertions, 6 deletions
diff --git a/backup.sh b/backup.sh
index 1caee22..8008f8c 100755
--- a/backup.sh
+++ b/backup.sh
@@ -25,9 +25,10 @@ function source_section {
line_end=$(expr $(grep -n "$section_end" "$config_name" | cut -d: -f1) - 1)
line_diff=$(expr $line_end - $line_start)
- head -n $line_end "$config_name" | tail -n $line_diff > /tmp/backup.tmp
- source /tmp/backup.tmp
- rm -f /tmp/backup.tmp
+ tmp_file=$(mktemp)
+ head -n $line_end "$config_name" | tail -n $line_diff > "$tmp_file"
+ source "$tmp_file"
+ rm -f "$tmp_file"
}
# copy file with rsync to server and save last timestamp to logfile
@@ -35,9 +36,9 @@ function rsync_server {
filefrom="$1"
dirto="$2"
logfileentry="$3"
- #nice -n 19 rsync -rle "ssh -i $keyfile" "$1" "$userserver:$dirto"
+ #nice -n 19 rsync -rle "ssh -i $keyfile" "$filefrom" "$userserver:$dirto"
# limit the bandwith
- nice -n 19 rsync --bwlimit=100000 -rle "ssh -i $keyfile" "$1" "$userserver:$dirto"
+ nice -n 19 rsync --bwlimit=100000 -rle "ssh -i $keyfile" "$filefrom" "$userserver:$dirto"
ret=$?
if [ $ret -ne 0 ]
then
@@ -46,7 +47,7 @@ function rsync_server {
echo "$filefrom" | grep ".month." > /dev/null 2>&1
ret2=$?
# on monthly backups and connection errors there should be no update of logfile
- if [ $ret2 -ne 0 -a $ret -e 0 ]
+ if [ $ret2 -ne 0 -a $ret -eq 0 ]
then
sed -e "s/^$logfileentry .*$/${logfileentry} $backup_time/" "$logfile" > "$logfile.tmp"
mv -f "$logfile.tmp" "$logfile"