MySQL backup implementation

This commit is contained in:
gospodar 2023-02-11 11:49:22 +01:00
parent 6fa438e81e
commit 223eff0d1b
2 changed files with 18 additions and 1 deletions

View File

@ -21,4 +21,9 @@ target_key='/home/xyz/.ssh/rsync' # rsync key
docker_enabled=false # will you use docker backup docker_enabled=false # will you use docker backup
docker_images=false # backup docker images docker_images=false # backup docker images
docker_volumes=false #backup docker volumes docker_volumes=false #backup docker volumes
docker_data=false #backup container information docker_data=false #backup container information
db_backup=false #backup databases
database_type=mysql #mysql or postgresql
db_username=user #database user
db_password=user #database password
db_name=user #name of the database

12
main.sh
View File

@ -233,6 +233,18 @@ function dockerbackup {
fi fi
} }
function backup_db {
if [ "$db_backup" = true ]
then
echo "Backing up database..." >&2
mkdir -p $tmpdir/db
if [ "$database_type" = "mysql" ]
then
mysqldump -u "$db_username" -p"$db_password" "$db_name" > $tmpdir/db/db.sql
elif [ "$database_type" = "postgresql" ]
echo "soon"
}
function runbackup { function runbackup {
# init, config check # init, config check
init init