This commit is contained in:
parent
e1ffc66b71
commit
d0d187f203
@ -4,6 +4,7 @@ from dotenv import load_dotenv
|
|||||||
from AppriseClient import apprise_notify
|
from AppriseClient import apprise_notify
|
||||||
from HealthchecksIO import healthcheck_ping
|
from HealthchecksIO import healthcheck_ping
|
||||||
import requests as r
|
import requests as r
|
||||||
|
import subprocess
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
r.packages.urllib3.disable_warnings()
|
r.packages.urllib3.disable_warnings()
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ def to_bool(value):
|
|||||||
# switches
|
# switches
|
||||||
docker_command = to_bool(os.getenv("docker_command"))
|
docker_command = to_bool(os.getenv("docker_command"))
|
||||||
rclone_copy = to_bool(os.getenv("rclone_copy"))
|
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"))
|
rclone_push = to_bool(os.getenv("rclone_push"))
|
||||||
restic_push = to_bool(os.getenv("restic_push"))
|
restic_push = to_bool(os.getenv("restic_push"))
|
||||||
db_dump = to_bool(os.getenv("db_dump"))
|
db_dump = to_bool(os.getenv("db_dump"))
|
||||||
@ -90,15 +92,17 @@ if db_dump:
|
|||||||
|
|
||||||
# Local rclone backup
|
# Local rclone backup
|
||||||
if rclone_copy:
|
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
|
# Remote rclone backup
|
||||||
if rclone_push:
|
if rclone_push:
|
||||||
if not os.path.exists(rclone_config_path):
|
os.system(f'rclone sync -P {seafile_data_local} {rclone_remote}:{rclone_remote_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}')
|
|
||||||
|
|
||||||
# Remote restic backup
|
# Remote restic backup
|
||||||
if restic_push:
|
if restic_push:
|
||||||
@ -116,13 +120,12 @@ if zip_db_files:
|
|||||||
|
|
||||||
# offload db file
|
# offload db file
|
||||||
if offload_db_files:
|
if offload_db_files:
|
||||||
os.system(f'rclone copy --config {rclone_config_path} -P \
|
os.system(f'rclone copy -P {db_dump_tmp_path} {rclone_remote}:{rclone_remote_db_path}')
|
||||||
{db_dump_tmp_path} {rclone_remote}:{rclone_remote_db_path}')
|
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
if cleanup:
|
if cleanup:
|
||||||
os.system(f'rm {db_dump_tmp_path}*sfdb_*')
|
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}')
|
{rclone_db_retention} {rclone_remote}:{rclone_remote_db_path}')
|
||||||
|
|
||||||
# healthcheck
|
# healthcheck
|
||||||
|
Loading…
x
Reference in New Issue
Block a user