Add lxd-export script + databases zfs dataset
This commit is contained in:
parent
58926a218e
commit
05f8068a75
2 changed files with 55 additions and 0 deletions
7
files/lxd-export.sh
Normal file
7
files/lxd-export.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd /var/backups/lxd
|
||||
for i in $(lxc list --format csv -c n); do
|
||||
lxc export $i ${i}.tar --instance-only --optimized-storage --compression none
|
||||
done
|
|
@ -9,6 +9,46 @@ apt.packages(
|
|||
update=True,
|
||||
)
|
||||
|
||||
files.directory(
|
||||
name='Ensure /var/backups/lxd exists',
|
||||
path='/var/backups/lxd',
|
||||
user='root',
|
||||
group='root',
|
||||
mode=700
|
||||
)
|
||||
|
||||
if not host.fact.command('zfs list | grep exports || true'):
|
||||
server.shell(
|
||||
name='Create ZFS volume exports',
|
||||
commands=['zfs create local/exports -o mountpoint=/var/backups/lxd']
|
||||
)
|
||||
|
||||
if not host.fact.command('mount | grep exports || true'):
|
||||
server.shell(
|
||||
name='Mount local/exports',
|
||||
commands=['zfs mount local/exports'],
|
||||
)
|
||||
|
||||
files.directory(
|
||||
name='Ensure /var/backups/databases exists',
|
||||
path='/var/backups/databases',
|
||||
user='root',
|
||||
group='root',
|
||||
mode=700
|
||||
)
|
||||
|
||||
if not host.fact.command('zfs list | grep databases || true'):
|
||||
server.shell(
|
||||
name='Create ZFS volume databases',
|
||||
commands=['zfs create local/databases -o mountpoint=/var/backups/databases']
|
||||
)
|
||||
|
||||
if not host.fact.command('mount | grep databases || true'):
|
||||
server.shell(
|
||||
name='Mount local/databases',
|
||||
commands=['zfs mount local/databases'],
|
||||
)
|
||||
|
||||
files.template(
|
||||
name='Push borgmatic config',
|
||||
src='templates/borgmatic.yaml.j2',
|
||||
|
@ -18,3 +58,11 @@ files.template(
|
|||
group='root',
|
||||
)
|
||||
|
||||
files.put(
|
||||
name='Push lxd-export script',
|
||||
src='files/lxd-export.sh',
|
||||
dest='/usr/local/bin/lxd-export.sh',
|
||||
user='root',
|
||||
group='root',
|
||||
mode='700',
|
||||
)
|
||||
|
|
Reference in a new issue