Script de backup Restic para Vaultwarden

Nota: Posts relacionados:

Configurando o script de backup

Primeiro, gere a senha de criptografia usando

generate_restic_password.sh
pwgen 30 > .restic_password

Certifique-se de fazer backup desta senha separadamente ou TODOS OS SEUS DADOS SERÃO PERDIDOS!

Agora crie backup.sh no mesmo diretório que docker-compose.yml:

vaultwarden_backup.sh
#!/bin/bash
export NAME=$(basename $(pwd))
export RESTIC_REPOSITORY=rest:http://restic:abc123@10.1.2.3:16383/$NAME
export RESTIC_PASSWORD_FILE=.restic_password

if [ ! -f "${RESTIC_PASSWORD_FILE}" ]; then
   echo "Please create .restic_password with the backup encryption password AND BACKUP THAT PASSWORD SEPARATELY!!!"
   exit 1
fi
echo "Initing repo, please ignore any 'already exists' errors"
if [ ! -f ".restic_inited" ]; then
    # Run the restic init command
    restic init

    if [ $? -eq 0 ]; then # if init successful
        # Create the initialization file
        touch ".restic_inited"
        echo "Restic initialized"
    fi
fi

# Backup
source .env
docker-compose exec -T mariadb mysqldump -uroot -p${MARIADB_ROOT_PASSWORD} --all-databases | restic --verbose backup --stdin --stdin-filename="mariadb.sql"
# Backup files
restic --verbose backup vw_data backup.sh --exclude vw_data/icon_cache

Iniciando automaticamente o script de backup

Veja Como Criar Um Timer & Service De Backup Systemd Em 10 Segundos

TL;DR: No diretório onde backup.sh reside, execute

create_backup_service.sh
wget -qO- https://techoverflow.net/scripts/create-backup-service.sh | sudo bash /dev/stdin

Check out similar posts by category: Restic Backup