Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tjibbevanderlaan/4b854c5ed9b3c8322bdfdc11ab27a87c to your computer and use it in GitHub Desktop.
Save tjibbevanderlaan/4b854c5ed9b3c8322bdfdc11ab27a87c to your computer and use it in GitHub Desktop.
Script to backup docker compose files
#!/bin/bash
####################################
#
# Backup of docker compose configuration files
#
####################################
# What to backup.
backup_files="/srv"
# Where to backup to.
dest="/mnt/docker-compose-backup"
mkdir -p $dest
# Create archive filename
month=$(date +%m)
hostname=$(hostname -s)
archive_file="$hostname-$month-docker-compose-backup.tgz"
# Print start status message.
echo "Backing up $backup_files to $dest/$archive_file"
date
echo
# Backup the files using tar.
tar --exclude='*.db*' -czf $dest/$archive_file $backup_files
# Print end status message.
echo
echo "Backup finished"
date
# Long listing of files in $dest to check file sizes.
ls -lh $dest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment