Created
February 7, 2022 20:29
-
-
Save codemicro/7bdc6df50de58fdf57752458f0516cd4 to your computer and use it in GitHub Desktop.
Basic rclone-based backup solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import os | |
import datetime | |
import json | |
datestring = datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d_%Hh%Mm") | |
filename = f"server_{datestring}.tar.gz" | |
to_backup = None | |
with open(os.path.join(os.path.expandvars("$HOME"), "backupConfig.json")) as f: | |
to_backup = json.load(f) | |
subprocess.run(['tar', '-czvf', filename,] + to_backup) | |
subprocess.run(['rclone', 'copy', "-v", filename, 'gd:/server']) | |
os.remove(filename) | |
subprocess.run(['rclone', 'delete', "-v", '--min-age', '15d', 'gd:/server']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment