Add lxd-databases backup
This commit is contained in:
parent
4c5691177c
commit
d6e822edc2
3 changed files with 23 additions and 0 deletions
12
files/lxd-databases.sh
Normal file
12
files/lxd-databases.sh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd /var/backups/databases
|
||||||
|
for i in $(lxc list --format csv -c n); do
|
||||||
|
if lxc exec $i -- which mysql; then
|
||||||
|
lxc exec $i -- mysqldump --opt --all-databases --force --events --hex-blob | cat > ${i}.sql
|
||||||
|
if
|
||||||
|
if lxc exec $i -- which psql; then
|
||||||
|
lxc exec $i -- sudo -u postgres pg_dumpall | cat > ${i}.sql
|
||||||
|
fi
|
||||||
|
done
|
|
@ -66,3 +66,13 @@ files.put(
|
||||||
group='root',
|
group='root',
|
||||||
mode='700',
|
mode='700',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
files.put(
|
||||||
|
name='Push lxd-databases script',
|
||||||
|
src='files/lxd-databases.sh',
|
||||||
|
dest='/usr/local/bin/lxd-databases.sh',
|
||||||
|
user='root',
|
||||||
|
group='root',
|
||||||
|
mode='700',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ hooks:
|
||||||
before_backup:
|
before_backup:
|
||||||
- echo "`date` - Starting backup"
|
- echo "`date` - Starting backup"
|
||||||
- /usr/local/bin/lxd-export.sh
|
- /usr/local/bin/lxd-export.sh
|
||||||
|
- /usr/local/bin/lxd-databases.sh
|
||||||
|
|
||||||
after_backup:
|
after_backup:
|
||||||
- echo "`date` - Finished backup"
|
- echo "`date` - Finished backup"
|
||||||
|
|
Reference in a new issue