docker-vackup icon indicating copy to clipboard operation
docker-vackup copied to clipboard

Use on Linux servers and project updates

Open cairoapcampos opened this issue 1 year ago • 5 comments

I was looking for a solution to backup volumes via Docker CLI. I found Vackup and tested it. I found it interesting because I can use it in bash scripts to backup volumes from different containers on Linux servers. Will this project continue to be updated? I tested the backup of an application volume and a bank volume. Backup and restore worked perfectly!

Do you have any advice on using this tool in a production environment?

cairoapcampos avatar Nov 01 '23 19:11 cairoapcampos

Hey there. I don't think this will need many (or any) updates because 1. it's just bash and 2. it's just basic docker commands that have worked for 10 years without edits.

In real storage, you usually need more than a file copy for backups. Databases all have their own backup tools to ensure you get proper backups, and backup systems usually are on a schedule, do retries, etc. This script isn't meant to replace a full backup system, but just an easy way to copy volumes from one system to another.

BretFisher avatar Nov 15 '23 03:11 BretFisher

I was able to create a shell script that uses the vackup script. This way I can backup all volumes on the system. Look:

#!/bin/bash

# Note: Before running this script, install the Vackup command,
# installation information can be found at the link below:
# https://github.com/BretFisher/docker-vackup

clear

## Variables
volumes=$(docker volume ls -q)
dts=$(date +%d%m%y_%H%M%S)
pathroot=/backup
pathbkp=$pathroot/$dts

## Remove subfolders from the backup directory that are more than 7 days old
find $pathroot -mindepth 1 -maxdepth 1 -type d -mtime +7 -exec rm -r {} \;

## Create and enter the backup directory
mkdir $pathbkp && cd $pathbkp

## Backing up volumes and creating backup logs
for volume in $volumes
do
    /usr/local/bin/vackup export $volume $volume.tar.gz | tee log_$volume.txt
done

cairoapcampos avatar Nov 16 '23 19:11 cairoapcampos

I was able to create a shell script that uses the vackup script. This way I can backup all volumes on the system. Look:

Thanks for your script. I managed to create a systemd service with your script to automate the backup once every day. If anyone is interested : Vackup all

cerebrux avatar Dec 26 '23 00:12 cerebrux

@cerebrux I'm very happy to know that my script was useful to you.

cairoapcampos avatar Dec 28 '23 19:12 cairoapcampos

In case anybody is interested, I'm using this script to backup all my containers. The main differences are, that the script stops all running containers before copying the volumes and restarting stopped containers, and also that it uses the docker-autocompose script as well to generate a compose file with all containers.

Guiorgy avatar Feb 07 '24 10:02 Guiorgy