diff --git a/.rclone.conf b/.rclone.conf index 88a0076..f2d7cd2 100644 --- a/.rclone.conf +++ b/.rclone.conf @@ -2,5 +2,5 @@ type = drive client_id = 128201014754-taqknehjoujjrprr2jp22sr2hr67tj4p.apps.googleusercontent.com client_secret = HFJbDGbf61Yf0WAi_HyKw7Bg -token = {"access_token":"ya29.GlxZBn5NX50H2v8QcDq5f1dnEyWDbHiZVlFd35KFuzS9bTefdHn54hqtH2S2xbbT8MgPFpHUUCwopLFneCbm7IsIRpqypA9CwLjNJW7Rl4wlPfnrk78RLSdfVT2QpA","token_type":"Bearer","refresh_token":"1/jjCubK4AGGU56INS9yeh2fMCQ8SCPNbltgJXw_ccTHc","expiry":"2018-11-19T08:47:56.315304763+01:00"} +token = {"access_token":"ya29.GlxZBqnc63MH4ojPptjnXexZ4hkfcekjbV2BQNleOAsskVK6GpoHCykTtibiDxVhaR_o1jqyZrhtxhiYKevC98ByZbZXngl2eCQE41cS4BD7-CCjDyeylc4BHJw2dA","token_type":"Bearer","refresh_token":"1/jjCubK4AGGU56INS9yeh2fMCQ8SCPNbltgJXw_ccTHc","expiry":"2018-11-19T12:42:40.171077114Z"} diff --git a/Dockerfile b/Dockerfile index 2f4a06a..d73e39f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ FROM plexinc/pms-docker COPY root / +RUN apt update && apt install -y cron + ENTRYPOINT ["/init"] diff --git a/docker-compose.yml b/docker-compose.yml index 6a16f7f..4b64c83 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,8 @@ services: - ./.rclone.conf:/root/.rclone.conf environment: - TZ=DE - - BACKUP=gdrive:/Backup/pms.tar.gz + - BACKUP=gdrive:/Backup/Plex-Dev + - CRON=4 + - PLEX_CLAIM=claim-z3PqezuUozjYLvv7LakC ports: - 32400:32400 diff --git a/root/etc/cont-finish.d/99-plex-cfg-backup b/root/etc/cont-finish.d/99-plex-cfg-backup index b1ca931..500b156 100755 --- a/root/etc/cont-finish.d/99-plex-cfg-backup +++ b/root/etc/cont-finish.d/99-plex-cfg-backup @@ -1,7 +1,6 @@ #!/usr/bin/with-contenv bash -# Creating a backup of plex configuration +# Remove crontab + +crontab -r -cd /config -tar -cvzf /pms.tar.gz Library -rclone move /pms.tar.gz $BACKUP --verbose --transfers 4 --checkers 20 --stats 10s diff --git a/root/etc/cont-init.d/30-plex-cfg b/root/etc/cont-init.d/30-plex-cfg index 39b3eb5..cd9cd9f 100755 --- a/root/etc/cont-init.d/30-plex-cfg +++ b/root/etc/cont-init.d/30-plex-cfg @@ -13,3 +13,6 @@ else tar -xvzf /pms.tar.gz fi fi + +echo "0 $CRON * * * /root/bin/backup-pms" > /root/crontab.txt +crontab /root/crontab.txt diff --git a/root/root/bin/backup-pms b/root/root/bin/backup-pms new file mode 100755 index 0000000..d7d21e9 --- /dev/null +++ b/root/root/bin/backup-pms @@ -0,0 +1,8 @@ +#!/usr/bin/with-contenv bash +# Creates a backup of Plex configuration library and pushes it to the backup repo +# +cd /config +tar -cvzf /pms.tar.gz Library + +rclone move /pms.tar.gz $BACKUP --verbose --transfers 4 --checkers 20 --stats 10s + diff --git a/test b/test new file mode 100644 index 0000000..6e7353b --- /dev/null +++ b/test @@ -0,0 +1,24 @@ +# Edit this file to introduce tasks to be run by cron. +# +# Each task to run has to be defined through a single line +# indicating with different fields when the task will be run +# and what command to run for the task +# +# To define the time you can provide concrete values for +# minute (m), hour (h), day of month (dom), month (mon), +# and day of week (dow) or use '*' in these fields (for 'any').# +# Notice that tasks will be started based on the cron's system +# daemon's notion of time and timezones. +# +# Output of the crontab jobs (including errors) is sent through +# email to the user the crontab file belongs to (unless redirected). +# +# For example, you can run a backup of all your user accounts +# at 5 a.m every week with: +# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ +# +# For more information see the manual pages of crontab(5) and cron(8) +# +# m h dom mon dow command + +0 2 * * * test