Added DB utils

This commit is contained in:
Jonathan Ervine 2020-08-17 23:02:38 +08:00
parent 3483d642d9
commit 76e27349df
2 changed files with 4 additions and 2 deletions

View File

@ -16,5 +16,7 @@ RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositorie
rm -rf /var/cache/apk/*
COPY start.sh /usr/local/bin/start.sh
COPY db-backup.py /usr/local/bin/db-backup.py
COPY db-restore.py /usr/local/bin/db-restore.py
CMD [ "/usr/local/bin/start.sh", "$LIVE_DB", "$BACXKUP_DB" ]

View File

@ -8,12 +8,12 @@ echo -e 'Starting the sidecar container to periodically backup the sonarr databa
chown 1003:1003 /app-remote-config/*
echo -e 'Copy the config from the remote share to the locali drive'
touch /mnt/app-local-config/$LIVE_DB
python3 /app-remote-config/db-restore.py $BACKUP_DB $LIVE_DB
python3 /usr/local/bin/db-restore.py $BACKUP_DB $LIVE_DB
find /app-remote-config/ -type -f -not -iname $BACKUP_DB -exec cp -fvp '{}' '/mnt/app-local-config/{}' ';'
chown -R 1003:1003 /mnt/app-local-config
echo -e 'Perform periodic backup of database'
while true; do
sleep 890
date
python3 /app-remote-config/db-backup.py $LIVE_DB $BACKUP_DB
python3 /usr/local/bin/db-backup.py $LIVE_DB $BACKUP_DB
done