diff --git a/db/reload.sh b/db/reload.sh new file mode 100755 index 0000000..e14ebfe --- /dev/null +++ b/db/reload.sh @@ -0,0 +1,7 @@ +#!/bin/sh +pandoractl stop +sudo -H -u postgres dropdb pandora +sudo -H -u postgres createdb -T template0 --locale=C --encoding=UTF8 -O pandora pandora +zcat /srv/pandora/data/db/latest.psql.gz | pandoractl manage dbshell +pandoractl start + diff --git a/db/sync_pandora.sh b/db/sync_pandora.sh new file mode 100755 index 0000000..b84d4c8 --- /dev/null +++ b/db/sync_pandora.sh @@ -0,0 +1,5 @@ +#!/bin/bash +rsync -avP time:/srv/pandora/data/ /srv/pandora/data/ +bash /srv/pandora/data/db/reload.sh +rsync -avP time:/srv/pandora/data/ /srv/pandora/data/ --delete +pandoractl manage generate_clips diff --git a/db/update.sh b/db/update.sh new file mode 100755 index 0000000..7fea261 --- /dev/null +++ b/db/update.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cd /srv/pandora/data/db +pg_dump pandora | gzip > pandora-`date -I`.psql.gz +ln -sf pandora-`date -I`.psql.gz latest.psql.gz diff --git a/etc/systemd/system/pandora-backup-db.service b/etc/systemd/system/pandora-backup-db.service new file mode 100644 index 0000000..c8dc18b --- /dev/null +++ b/etc/systemd/system/pandora-backup-db.service @@ -0,0 +1,8 @@ +Unit] +Description=Backup pandora database + +[Service] +Type=oneshot +User=pandora +Group=pandora +ExecStart=/srv/pandora/db/update.sh diff --git a/etc/systemd/system/pandora-backup-db.timer b/etc/systemd/system/pandora-backup-db.timer new file mode 100644 index 0000000..a5e7805 --- /dev/null +++ b/etc/systemd/system/pandora-backup-db.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Backup pandora database + +[Timer] +OnCalendar=*-*-* 4:00 +Persistent=true + +[Install] +WantedBy=timers.target