aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2017-03-28 10:07:38 +0200
committerlookshe <github@lookshe.org>2017-03-28 10:07:38 +0200
commitd007c2e3c54a7012af1e2576e61200b7d4dd3918 (patch)
treec8e5302945ee7b853fc6b844e3b37e91200167f3
parentaed0f66e7f60f343f5d486dbcf621253cdfabb30 (diff)
check return from borg init
-rwxr-xr-xbackup.sh14
-rwxr-xr-xbackup_db.sh13
2 files changed, 25 insertions, 2 deletions
diff --git a/backup.sh b/backup.sh
index 6a3a5d7..26ae664 100755
--- a/backup.sh
+++ b/backup.sh
@@ -64,6 +64,7 @@ function check_borg_repo {
repo="$1"
serverdir="$2"
usesamerepo="$3"
+ ret=0
if [ "$usesamerepo" = "yes" ]
then
repo_path="$userserver:$backupdir/$serverdir"
@@ -76,7 +77,13 @@ function check_borg_repo {
then
# create repo if not exists
$nice $borg_local_path init --remote-path "$borg_remote_path" --encryption "$borg_encryption" "$repo_path"
+ if [ $? -ne 0 ]
+ then
+ $echo "problem in borg init $repo"
+ ret=1
+ fi
fi
+ return $ret
}
# backup single dir with borg
@@ -85,7 +92,11 @@ function backup_dir {
serverdir="$2"
logfileentry="$3"
usesamerepo="$4"
- check_borg_repo "$repo" "$serverdir" "$usesamerepo"
+ check_borg_repo "$repo" "$serverdir" "$usesamerepo"
+ if [ $? -ne 0 ]
+ then
+ return 1
+ fi
# to get backup.ignore work with relative paths we need to change the directory
pushd "$repo" > /dev/null
if [ "$usesamerepo" = "yes" ]
@@ -111,6 +122,7 @@ function backup_dir {
else
$echo "problem in borg create $repo"
fi
+ return 0
}
# general section from main config
diff --git a/backup_db.sh b/backup_db.sh
index 90b9b72..5a951b0 100755
--- a/backup_db.sh
+++ b/backup_db.sh
@@ -67,6 +67,7 @@ function check_borg_repo {
repo="$1"
serverdir="$2"
usesamerepo="$3"
+ ret=0
if [ "$usesamerepo" = "yes" ]
then
repo_path="$userserver:$backupdir/$serverdir"
@@ -79,7 +80,13 @@ function check_borg_repo {
then
# create repo if not exists
$nice $borg_local_path init --remote-path "$borg_remote_path" --encryption "$borg_encryption" "$repo_path"
+ if [ $? -ne 0 ]
+ then
+ $echo "problem in borg init $repo"
+ ret=1
+ fi
fi
+ return $ret
}
# backup single dir with borg
@@ -87,7 +94,11 @@ function backup_db {
repo="$1"
serverdir="$2"
usesamerepo="$3"
- check_borg_repo "$repo" "$serverdir" "$usesamerepo"
+ check_borg_repo "$repo" "$serverdir" "$usesamerepo"
+ if [ $? -ne 0 ]
+ then
+ return 1
+ fi
# to get backup.ignore work with relative paths we need to change the directory
if [ "$usesamerepo" = "yes" ]
then