Dump all databases, refactoring, docs
This commit is contained in:
parent
59a370ba74
commit
5183b9bc7d
@ -35,6 +35,11 @@ All configuration options can be found in the `backup.cfg` file. The script has
|
||||
| docker_images | true/false | Backup Docker images |
|
||||
| docker_volumes | true/false | Backup Docker volumes |
|
||||
| docker_data | true/false | Backup container information |
|
||||
| db_backup | true/false | Backup database |
|
||||
| database_type | mysql/postgresql | Database type |
|
||||
| db_username | ------> | Username for DB access |
|
||||
| db_password | ------> | Password for DB access |
|
||||
| db_name | ------> | Name of database |
|
||||
|
||||
To-Do List
|
||||
----------
|
||||
@ -42,8 +47,5 @@ To-Do List
|
||||
- [ ] Rsync implementation via shell
|
||||
- [ ] Rsync implementation via Docker
|
||||
- [ ] Cron scheduler
|
||||
- [x] RHEL/Ubuntu parser
|
||||
- [x] Automatic adjustments per system
|
||||
- [x] MySQL backups
|
||||
- [ ] PostgreSQL backups
|
||||
- [ ] Cover more system logs
|
@ -26,4 +26,5 @@ db_backup=false #backup databases
|
||||
database_type=mysql #mysql or postgresql
|
||||
db_username=user #database user
|
||||
db_password=user #database password
|
||||
db_all=false #dumps all databases if true
|
||||
db_name=user #name of the database
|
23
main.sh
23
main.sh
@ -234,15 +234,23 @@ function dockerbackup {
|
||||
}
|
||||
|
||||
function backup_db {
|
||||
if [ "$db_backup" = true ]
|
||||
if [ "$db_all" = 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
|
||||
mysqldump -u "$db_username" -p"$db_password" --all-databases > $tmpdir/db/db_all.sql
|
||||
elif [ "$database_type" = "postgresql" ]
|
||||
echo "soon"
|
||||
then
|
||||
pg_dumpall -U "$db_username" -f $tmpdir/db/db_all.sql
|
||||
fi
|
||||
else
|
||||
if [ "$database_type" = "mysql" ]
|
||||
then
|
||||
mysqldump -u "$db_username" -p"$db_password" "$db_name" > $tmpdir/db/$db_name.sql
|
||||
elif [ "$database_type" = "postgresql" ]
|
||||
then
|
||||
pg_dump -U "$db_username" "$db_name" -f $tmpdir/db/$db_name.sql
|
||||
fi
|
||||
}
|
||||
|
||||
function runbackup {
|
||||
@ -269,6 +277,11 @@ function runbackup {
|
||||
fi
|
||||
# step 5: docker backup
|
||||
dockerbackup
|
||||
# step 6: db backup
|
||||
if [ "$db_backup" = true ]
|
||||
then
|
||||
backup_db
|
||||
fi
|
||||
# archive data
|
||||
echo "Creating backup archive..." >&2
|
||||
tar -czvf /opt/backify-$timestamp.tar.gz $tmpdir
|
||||
|
Loading…
Reference in New Issue
Block a user