This commit is contained in:
parent
e1ffc66b71
commit
d0d187f203
@ -4,6 +4,7 @@ from dotenv import load_dotenv
|
||||
from AppriseClient import apprise_notify
|
||||
from HealthchecksIO import healthcheck_ping
|
||||
import requests as r
|
||||
import subprocess
|
||||
now = datetime.now()
|
||||
r.packages.urllib3.disable_warnings()
|
||||
|
||||
@ -24,6 +25,7 @@ def to_bool(value):
|
||||
# switches
|
||||
docker_command = to_bool(os.getenv("docker_command"))
|
||||
rclone_copy = to_bool(os.getenv("rclone_copy"))
|
||||
rclone_config_create = to_bool(os.getenv("rclone_config_create"))
|
||||
rclone_push = to_bool(os.getenv("rclone_push"))
|
||||
restic_push = to_bool(os.getenv("restic_push"))
|
||||
db_dump = to_bool(os.getenv("db_dump"))
|
||||
@ -90,15 +92,17 @@ if db_dump:
|
||||
|
||||
# Local rclone backup
|
||||
if rclone_copy:
|
||||
os.system(f'rclone sync --config {rclone_config_path} -P {seafile_data_local} {seafile_data_backup}')
|
||||
os.system(f'rclone sync -P {seafile_data_local} {seafile_data_backup}')
|
||||
|
||||
if rclone_config_create:
|
||||
rclone_config_check = str(subprocess.check_output(["rclone", "config", "file"]))
|
||||
if "doesn't exist" in rclone_config_check:
|
||||
os.system(f"rclone config create {rclone_remote} {rclone_backend} provider={rclone_provider}\
|
||||
endpoint={rclone_endpoint} env_auth=true")
|
||||
|
||||
# Remote rclone backup
|
||||
if rclone_push:
|
||||
if not os.path.exists(rclone_config_path):
|
||||
os.system(f"rclone config create --config {rclone_config_path} {rclone_remote} {rclone_backend} provider={rclone_provider}\
|
||||
endpoint={rclone_endpoint} env_auth=true")
|
||||
os.system(f'rclone sync --config {rclone_config_path} -P \
|
||||
{seafile_data_local} {rclone_remote}:{rclone_remote_path}')
|
||||
os.system(f'rclone sync -P {seafile_data_local} {rclone_remote}:{rclone_remote_path}')
|
||||
|
||||
# Remote restic backup
|
||||
if restic_push:
|
||||
@ -116,13 +120,12 @@ if zip_db_files:
|
||||
|
||||
# offload db file
|
||||
if offload_db_files:
|
||||
os.system(f'rclone copy --config {rclone_config_path} -P \
|
||||
{db_dump_tmp_path} {rclone_remote}:{rclone_remote_db_path}')
|
||||
os.system(f'rclone copy -P {db_dump_tmp_path} {rclone_remote}:{rclone_remote_db_path}')
|
||||
|
||||
# cleanup
|
||||
if cleanup:
|
||||
os.system(f'rm {db_dump_tmp_path}*sfdb_*')
|
||||
os.system(f'Rclone delete --config {rclone_config_path} -P \
|
||||
os.system(f'Rclone delete -P \
|
||||
{rclone_db_retention} {rclone_remote}:{rclone_remote_db_path}')
|
||||
|
||||
# healthcheck
|
||||
|
Loading…
x
Reference in New Issue
Block a user