Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
role_simple_backup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SLUB - Referat 2.5
Ansible
role_simple_backup
Commits
6e89cb7d
Commit
6e89cb7d
authored
1 year ago
by
Hannes Braun
Browse files
Options
Downloads
Patches
Plain Diff
Add logging
parent
18258767
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
files/opt/simple-backup/simple-backup.sh
+16
-6
16 additions, 6 deletions
files/opt/simple-backup/simple-backup.sh
with
16 additions
and
6 deletions
files/opt/simple-backup/simple-backup.sh
+
16
−
6
View file @
6e89cb7d
...
...
@@ -25,7 +25,7 @@ nfs_mount_path=$(awk -F= -v section="$section" -v key="$key" '
'
$config_file
)
if
test
-z
"
$nfs_mount_path
"
;
then
echo
"
No nfs
volume
path was provided"
logger
"Simple-Backup: ERROR Code 1: Missing necessary configuration.
No nfs
mount
path was provided
.
"
exit
1
fi
...
...
@@ -40,7 +40,7 @@ nfs_server=$(awk -F= -v section="$section" -v key="$key" '
'
$config_file
)
if
test
-z
"
$nfs_server
"
;
then
echo
"No nfs volume path
was provided"
logger
"Simple-Backup: ERROR Code 1: Missing necessary configuration. No nfs server ip adress
was provided
.
"
exit
1
fi
...
...
@@ -55,7 +55,7 @@ nfs_volume_path=$(awk -F= -v section="$section" -v key="$key" '
'
$config_file
)
if
test
-z
"
$nfs_volume_path
"
;
then
echo
"
No nfs volume path was provided"
logger
"Simple-Backup: ERROR Code 1: Missing necessary configuration.
No nfs volume path was provided
.
"
exit
1
fi
...
...
@@ -73,7 +73,7 @@ source_directories=($(awk -F= -v section="$section" -v key="$key" '
'
$config_file
)
)
if
test
-z
"
$source_directories
"
;
then
echo
"
No source directory was provided"
logger
"Simple-Backup: ERROR Code 1: Missing necessary configuration.
No source directory was provided
.
"
exit
1
fi
...
...
@@ -93,7 +93,7 @@ excludes=($(awk -F= -v section="$section" -v key="$key" '
##### MOUNT
S
NFS SHARE #####
##### MOUNT NFS SHARE #####
if
[
!
-d
"
$nfs_mount_path
"
]
;
then
mkdir
-p
"
$nfs_mount_path
"
...
...
@@ -120,12 +120,22 @@ readonly BACKUP_DIR="${nfs_mount_path}/backups/${HOSTNAME}"
readonly
DATETIME
=
"
$(
date
'+%Y-%m-%d_%H:%M:%S'
)
"
readonly
BACKUP_PATH
=
"
${
BACKUP_DIR
}
/
${
DATETIME
}
"
readonly
LATEST_LINK
=
"
${
BACKUP_DIR
}
/latest"
readonly
LOG_FILE
=
"
${
BACKUP_PATH
}
.log"
mkdir
-p
"
${
BACKUP_DIR
}
"
rsync_cmd_str
=
"rsync -avR --delete
${
source_string
}
--link-dest
${
LATEST_LINK
}
${
exclude_string
}
${
BACKUP_PATH
}
"
echo
$rsync_cmd_str
$rsync_cmd_str
$rsync_cmd_str
&>>
"
$LOG_FILE
"
||
true
RSYNC_EXIT_CODE
=
$?
if
[
$RSYNC_EXIT_CODE
-eq
0
]
;
then
echo
"Simple-Backup: INFO Code 0: Rsync completed successfully."
&>>
"
$LOG_FILE
"
logger
"Simple-Backup: INFO Code 0: Rsync completed successfully."
else
echo
"Simple-Backup: ERROR Code
$RSYNC_EXIT_CODE
: Rsync ended with errors."
&>>
"
$LOG_FILE
"
logger
"Simple-Backup: ERROR Code
$RSYNC_EXIT_CODE
: Rsync ended with errors."
fi
rm
-rf
"
${
LATEST_LINK
}
"
ln
-s
"
${
BACKUP_PATH
}
"
"
${
LATEST_LINK
}
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment