Add stop/start of Docker container
This commit is contained in:
parent
803e948aa1
commit
8312e5be27
1 changed files with 12 additions and 0 deletions
12
backup.sh
12
backup.sh
|
|
@ -46,8 +46,15 @@ LOG_FILE="${LOG_DIR}/${SERVICE}_${DATE}.log"
|
|||
REPOSITORY_FILE="${CONFIG_DIR}/${SERVICE}_repository"
|
||||
PASSWORD_FILE="${CONFIG_DIR}/${SERVICE}_password"
|
||||
UUID_FILE="${CONFIG_DIR}/${SERVICE}_uuid"
|
||||
DOCKER_CONTAINER_FILE="${CONFIG_DIR}/${SERVICE}_container_name"
|
||||
|
||||
|
||||
echo -e "--- START OF BACKUP FOR ${SERVICE^^} - ${DATE} ---\n\n" > $LOG_FILE
|
||||
|
||||
# Stop Docker container
|
||||
echo -e "\n\n Shutting down container with container name $(<$DOCKER_CONTAINER_FILE)" >> $LOG_FILE
|
||||
docker container stop $(<$DOCKER_CONTAINER_FILE) >> $LOG_FILE
|
||||
|
||||
restic backup $INPUT --verbose --repository-file $REPOSITORY_FILE --password-file $PASSWORD_FILE >> $LOG_FILE
|
||||
|
||||
echo -e "\n\n Current snapshots:\n\n" >> $LOG_FILE
|
||||
|
|
@ -58,3 +65,8 @@ restic check --verbose --repository-file $REPOSITORY_FILE --password-file $PASSW
|
|||
|
||||
echo -e "\n\n Move to external storage:\n\n" >> $LOG_FILE
|
||||
rsync -rahPv --delete-after -e "ssh -p ${EXTERNAL_STORAGE_PORT}" "$(<$REPOSITORY_FILE)" $EXTERNAL_STORAGE_USER@$EXTERNAL_STORAGE_URL:$EXTERNAL_STORAGE_ROOT_DIR/"$(<$UUID_FILE)" >> $LOG_FILE
|
||||
|
||||
|
||||
# Start Docker container again
|
||||
echo -e "\n\n Starting container with container name $(<$DOCKER_CONTAINER_FILE)" >> $LOG_FILE
|
||||
docker container start $(<$DOCKER_CONTAINER_FILE) >> $LOG_FILE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue