Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Iseard
Backup Script
Commits
195c93d1
Commit
195c93d1
authored
Jul 31, 2019
by
Michael Iseard
Browse files
check_result now accepts exit code argument
parent
1d1561b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
backup.sh
View file @
195c93d1
...
...
@@ -28,41 +28,44 @@ fi
function
check_result
()
{
if
[
$?
-eq
0
]
;
then
echo
$done
echo
"
$done
"
else
echo
"
$fail
(exit code:
$?
)"
exit
1
if
[
"
$1
"
-gt
0
]
;
then
echo
"exiting..."
exit
"
$1
"
fi
fi
}
if
[[
!
-z
"
$IM_NFS_MOUNT_POINT
"
||
"
$IM_NFS_SOURCE
"
]]
;
then
echo
-n
'Mounting NFS.......'
$dots
sudo
mount
$IM_NFS_SOURCE
$IM_BACKUP_DESTINATION
check_result
check_result
1
fi
if
[
!
-z
"
$containers
"
]
;
then
echo
-n
'Stopping containers'
$dots
docker stop
$containers
>
/dev/null 2>&1
check_result
check_result
0
fi
echo
-n
'Sending backup.....'
$dots
borg create
$IM_BACKUP_DESTINATION
::
$name
$IM_BACKUP_SOURCE
check_result
check_result
0
echo
-n
'Pruning backups....'
$dots
borg prune
-sv
-d7
-w4
-m12
--show-rc
$IM_BACKUP_DESTINATION
>
/dev/null 2>&1
check_result
check_result
0
if
[[
!
-z
"
$IM_NFS_MOUNT_POINT
"
||
"
$IM_NFS_SOURCE
"
]]
;
then
echo
-n
'Unmounting backup..'
$dots
sudo
umount /nfs/BACKUP1/
check_result
check_result
0
fi
if
[
!
-z
"
$containers
"
]
;
then
echo
-n
'Starting containers'
$dots
docker start
$containers
>
/dev/null 2>&1
check_result
check_result
1
fi
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment