Created
April 2, 2022 19:35
-
-
Save tjibbevanderlaan/4b854c5ed9b3c8322bdfdc11ab27a87c to your computer and use it in GitHub Desktop.
Script to backup docker compose files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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