Code Monkey home page Code Monkey logo

alaub81 / backup_docker_scripts Goto Github PK

View Code? Open in Web Editor NEW
132.0 7.0 25.0 55 KB

with these script you are able to backup your docker environment. There is one for the compose project, for mysql or mariadb, for postgres SQL and for normal docker volumes.

Home Page: https://www.laub-home.de/wiki/Docker_Backup_und_Restore_-_eine_kleine_Anleitung

License: GNU Affero General Public License v3.0

Shell 100.00%
docker docker-compose postgres postgressql mysql mariadb backup docker-volumes

backup_docker_scripts's Introduction

Repository Description

with these script you are able to backup your docker environment. There is one for the compose project, for one mysql or mariadb, one for postgres SQL and one for the docker volumes.

Installation

Just download the needed Script/s to /usr/local/sbin and give them the excute (chmod +x SCRIPTNAME) then you could just start it from wherever you are in the filesystem.

Usage

backup-docker-volume.sh

This Script backups docker volumes of the system to a defined Path. You could define the volumes and the backup path in the script itself. Also you could configure the days, how long the backup files will remain as backup. After configuration of the script, you could just start it with:

backup-docker-volume.sh

backup-docker-mysql.sh

This Script backups mysql or mariaDB containers with mysqldump or mariadb-dump. If you are using more then one database within a container, the script will backup every used database. Just define the backup folder in the script and start it with:

backup-docker-mysql.sh

You can also configure the days, the backupfiles will remain in the backup folder.

Attention: If you are using Docker Secrets, it will not work. More informations here: #1

backup-docker-postgres.sh

This Script backups postgres database containers with pg_dumpall. Just define the backup folder in the script and start it with:

backup-docker-postgres.sh

You can also configure the days, the backupfiles will remain in the backup folder.

backup-docker-influxdb.sh

This Script backups influxdb database containers with influx backup. Just define the backup folder in the script mount it into the container under /backup and start it with:

backup-docker-influxdb.sh

You can also configure the days, the backupfiles will remain in the backup folder.

backup-docker-compose.sh

With the help of backup-docker-compose.sh you are able to backup the whole docker-compose project folder of each docker-compose project you are running. It uses tar.gz to archive all the files and folders to the predifined backup folder. Just configure the script in the top and run it:

backup-docker-compose.sh

You can also configure the days, the backupfiles will remain in the backup folder.

recovery-docker-mysql.sh

With that script you are able to select the previous stored backup (BACKUPDIR=/backup/mysql pls change that, if needed) and recover it to the same Container and Database.

  • Just store the Script in /usr/local/sbin and make it executable: sudo chmod +x /usr/local/sbin/recovery-docker-mysql.sh
  • To start a recovery, execute the script with the following command: sudo ./recovery-docker-mysql.sh
    (root permission is needed as it will grap the MySQL root pw from the Docker Env. If you are using Docker Secrets, it will not work. You need to store the PW in the Script manually: MYSQL_PWD='yourpw')

The script will read trough the backup store and will ask you to select the Container, Database and Backup (Date-Time) you want to recover. When you then approve the task at the end of the script, it will start a recovery within the docker container. (There is no mysql completion message, but you will get a security issue, as a cleartype password is used to connect to mysql)

More Informations you could find here:

backup_docker_scripts's People

Contributors

alaub81 avatar deliciousbob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

backup_docker_scripts's Issues

Synology NAS

does these scripts also work for docker in synology nas? I can´t find the path /usr/local/sbin there - so I tried to start a script from somewhere else but nothing happened

Postgres user

Hallo

danke für das Script, allerdings bekomme ich einen Fehler und der dump ist leer.

Start 202112060549 Backup for Databases: 

 create Backup for Database on Container:
  * meine_db

/usr/lib/postgresql/9.5/bin/pg_dumpall: option requires an argument -- 'U'
Try "pg_dumpall --help" for more information.

202112060549 Backup for Databases completed

wenn ich in den User hardcoded in das Script schreibe klappt es:

docker exec $i pg_dumpall -c -U postgres | gzip > $BACKUPDIR/$i-$TIMESTAMP.sql.gz

LG opaque

Mysql Backups are only 1KB

Hello there!

I tried the backup script for mysql/mariadb and the output files are only 1KB.
There are no errors during runtime, except

 create Backup for Database on Container:
  * /run/secrets/mariadb_database DB on mariadb_baikal
./mariadb_backup.sh: line 58: /docker/backup/database/mariadb/mariadb_baikal-/run/secrets/mariadb_database-202111231913.sql.gz: No such file or directory
mysqldump: Got error: 1045: "Access denied for user 'root'@'localhost' (using password: YES)" when trying to connect
ls: cannot access '/docker/backup/database/mariadb/mariadb_baikal*.gz': No such file or directory

But this error only happens with two different containers, there are no errors with the other containers, although i deployed them the same way, so i don't get it, why an error occurs with these two containers.

Do you have an idea what to do?

Greetings

mariadb backup

Hello,

I just used the script with the Linuxserver mariaDB container and got this error:
" create MYSQL Backup for Database on Container:

  • DB on mariadb
    Usage: mysqldump [OPTIONS] database [tables]
    OR mysqldump [OPTIONS] --databases DB1 [DB2 DB3...]
    OR mysqldump [OPTIONS] --all-databases
    OR mysqldump [OPTIONS] --system=[SYSTEMOPTIONS]]
    For more options, use mysqldump --help"

I added --all-databases to the mysqldump within the script and then it works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.