From a3742e0e53af65f9374314f4e7432af8336a5c47 Mon Sep 17 00:00:00 2001 From: Michael <30936296+mtan93@users.noreply.github.com> Date: Sat, 18 Jan 2020 20:44:48 +0000 Subject: [PATCH] DB Sync Between 2 PGBlitz Hosts Not ready yet. USE AT YOUR OWN RISK. --- apps/dbsync | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 apps/dbsync diff --git a/apps/dbsync b/apps/dbsync new file mode 100644 index 0000000..4a8a026 --- /dev/null +++ b/apps/dbsync @@ -0,0 +1,69 @@ +#!/bin/bash +# +# Title: PGBlitz (Reference Title File) +# Author(s): Admin9705 +# URL: https://pgblitz.com - http://github.pgblitz.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + # FACTS ####################################################################### + - name: 'Set Known Facts' + set_fact: + pgrole: 'dbsync' + image: 'nowsci/plex-db-sync' + + # CORE (MANDATORY) ############################################################ + - name: 'Including cron job' + include_tasks: '/opt/communityapps/apps/_core.yml' + + # LABELS ###################################################################### + - name: 'Adding Traefik' + set_fact: + pg_labels: + author: 'AUO' + + - name: 'Setting PG Volumes' + set_fact: + pg_volumes: + - '/etc/localtime:/etc/localtime:ro' + - '/opt/appdata/{{pgrole}}:/config' + - './plex-db-sync/sshkey:/sshkey' + - '/opt/appdata/plex/database/Library/Application Support/Plex Media Server/Plug-in Support/Databases/:/mnt/DB2' + + - name: 'Setting PG ENV' + set_fact: + pg_env: + PUID: '1000' + PGID: '1000' + S1_SSH_KEY: '/sshkey' + S1_SSH_USER: 'root' + S1_SSH_HOST: 'yourhost' + S1_SSH_PORT: '22' + S1_SSH_PATH '/opt/appdata/plex/database/Library/Application Support/Plex Media Server/Plug-in Support/Databases/' + S1_START: 'ssh -oStrictHostKeyChecking=no -i /sshkey root@hostname cd /docker; docker-compose up -d plex' + S1_STOP: 'ssh -oStrictHostKeyChecking=no -i /sshkey root@hostname cd /docker; docker-compose stop plex' + S2_DB_PATH: '/mnt/DB2' + S2_START: 'cd /docker; docker container start plex' + S2_STOP: 'cd /docker; docker container stop plex' + CRON: '0 4 * * *' + + # MAIN DEPLOYMENT ############################################################# + - name: 'Deploying {{pgrole}}' + docker_container: + name: '{{pgrole}}' + image: '{{image}}' + pull: yes + published_ports: + - '{{ports.stdout}}{{extport}}:{{intport}}' + volumes: '{{pg_volumes}}' + env: '{{pg_env}}' + restart_policy: always + networks: + - name: plexguide + aliases: + - '{{pgrole}}' + state: stopped + labels: '{{pg_labels}}'