Skip to content

Commit

Permalink
Better docker logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Minituff committed Oct 9, 2023
1 parent e23d4a5 commit c378281
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dev
19 changes: 7 additions & 12 deletions pkg/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,40 +48,35 @@ BackupContainer() {
local container=$1

if [ -d "$SOURCE_LOCATION/$container" ]; then
log_entry "Directory $SOURCE_LOCATION/$container exists."

log_entry "Stopping $container..."
docker stop $container
docker stop $container 2>&1 >/dev/null
if [ $? -ne 0 ]; then
log_entry "Error stopping container $container. Skipping backup for this container."
return
fi

log_entry "Copying $SOURCE_LOCATION/$container to $DEST_LOCATION/$container..."
rsync -ah --info=progress2 --exclude '*.log' $SOURCE_LOCATION/$container/ $DEST_LOCATION/$container/
log_entry "Backing up $container data..."
rsync -ah -q --info=progress2 --exclude '*.log' $SOURCE_LOCATION/$container/ $DEST_LOCATION/$container/

if [ $? -ne 0 ]; then
log_entry "Error copying data for container $container. Skipping backup for this container."

log_entry "Starting $container..."
log_entry "Starting $container container..."
docker start $container
if [ $? -ne 0 ]; then
log_entry "Error restarting container $container. Please check manually!"
return
fi

return
else
log_entry "Copied $SOURCE_LOCATION/$container to $DEST_LOCATION/$container."
fi


log_entry "Starting $container..."
docker start $container
log_entry "Starting $container container..."
docker start $container 2>&1 >/dev/null
if [ $? -ne 0 ]; then
log_entry "Error restarting container $container. Please check manually!"
return
else
log_entry "Container $container restarted."
fi

log_entry "$container completed."
Expand Down

0 comments on commit c378281

Please sign in to comment.