| 1234567891011121314151617181920212223242526272829303132 |
- #!/bin/bash
- if [ "$#" -ne 1 ]; then
- echo "Error: Please provide the path to the config file." >&2
- echo "Usage: $0 <config file path>" >&2
- exit 1
- fi
- #Source external configuration
- . $1
- #Check if all variables are provided
- for var in backupFilepath dockerContainerName dataFilepath; do
- if [ -z "${!var}" ]; then
- echo "Error: Required config variable '$var' is not set or empty." >&2
- exit 1
- fi
- done
- #Create backup directories if not present
- mkdir -p ${backupFilepath}/database
- #mkdir -p ${backupFilepath}/attachments
- #Backup database
- docker exec -i ${dockerContainerName} /vaultwarden backup > /dev/null 2>&1
- #Copy file(s) over to destination
- mv ${dataFilepath}/db_*.sqlite3 ${backupFilepath}/database/
- #Backup rotation - Delete everything older than rotationDays
- find $backupFilepath -type f -mtime +$rotationDays -name '*.sqlite3' -execdir rm -- '{}' \;
|