added .env and refactor full backup

master
grumbulon 1 year ago
parent a82e4e0579
commit c1d9da7694
  1. 1
      .gitignore
  2. 13
      env-example
  3. 30
      fce-backup/backup.py

1
.gitignore vendored

@ -0,0 +1 @@
.env

@ -0,0 +1,13 @@
#Entire settings
PLEROMA="/opt/pleroma/"
#Static dirs
EMOTES="/opt/pleroma/instance/static/emoji/"
UPLOADS="/opt/pleroma/uploads/"
#OTP static
OTP="/var/lib/pleroma/"
#rsync settings
REMOTEUSER="grumbulon"
REMOTEHOST="YourHostHere"

@ -3,10 +3,11 @@ import subprocess
import argparse
import shutil
import os.path
from dotenv import load_dotenv
from datetime import datetime
todays_date = datetime.today().strftime("%m-%d")
pleroma_dirs = ('/var/lib/pleroma/static/emoji/', '/var/lib/pleroma/uploads/')
load_dotenv()
def dump_db(backup_path):
command = f"pg_dump -d pleroma --format=custom -f {backup_path}/pleroma-{todays_date}.pgdump"
@ -14,31 +15,20 @@ def dump_db(backup_path):
output, error = proc.communicate()
def zip_dirs(backup_path):
dirs = probe_pleroma_dirs()
if dirs:
for dir in pleroma_dirs:
stripped_dir = os.path.basename(os.path.normpath(f"{dir}"))
shutil.make_archive(f"{backup_path}/{stripped_dir}", 'zip', dir)
else:
return 1
def probe_pleroma_dirs():
for dir in pleroma_dirs:
dir_exists = False
if os.path.exists(dir):
dir_exists = True
if dir_exists:
return True
else:
return False
static_dir = os.getenv("EMOTES")
uploads_dir = os.getenv("UPLOADS")
backup_dirs = [static_dir, uploads_dir]
for dir in backup_dirs:
stripped_dir = os.path.basename(os.path.normpath(f"{dir}"))
shutil.make_archive(f"{backup_path}/{stripped_dir}", 'zip', dir)
def main():
args = arg_parser()
if args.full:
zip_dirs(args.path)
#dump_db(args.path)
dump_db(args.path)
def arg_parser():

Loading…
Cancel
Save