x86_64-alpine-db-sidecar/start.sh
Jonathan Ervine 32d5885669 modified: start.sh
Set to hardcoded mountpoints rather than variables, as these need to be
hardcoded in the container image anyway
2020-03-19 11:54:57 +08:00

24 lines
876 B
Bash

#!/bin/sh
##
## Script to automate the copy of databases running on a ramdisk to a permanent storage location
##
echo -e 'Starting the sidecar container to periodically backup the sonarr databases'
echo -e 'Create the ramdisk file'
dd if=/dev/zero of=/ramdisk/image.ext4 count=0 bs=1 seek=400M
echo -e 'Create filesystem on ramdisk file'
mkfs.ext4 /ramdisk/image.ext4
echo -e 'Mount the ramdisk file to /mnt/sonarr-ramdisk-mount'
mount /ramdisk/image.ext4 /mnt/db-ramdisk-mount
echo -e 'Initial copy of the config from the remote share to the ramdisk'
cp -fvp /perm-config/*.* /mnt/db-ramdisk-mount
echo -e 'Set up the filesystem freeze, copy, unfreeze loop'
while true; do
sleep 890
date
sync /mnt/db-ramdisk-mount/*.*
fsfreeze --freeze /mnt/db-ramdisk-mount
sleep 10
cp -fvp /mnt/db-ramdisk-mount/*.* /perm-config/
fsfreeze --unfreeze /mnt-ramdisk-mount
done