From 1a441009b6a7ab7c2fada48a0065b56cd071b893 Mon Sep 17 00:00:00 2001 From: Tilman Date: Mon, 27 Nov 2023 15:06:50 +0100 Subject: [PATCH] selective-backup.py --- python/selective-backup.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 python/selective-backup.py diff --git a/python/selective-backup.py b/python/selective-backup.py new file mode 100644 index 0000000..bd2248e --- /dev/null +++ b/python/selective-backup.py @@ -0,0 +1,29 @@ +import shutil +from datetime import datetime +import os + +daily_dir = "/media/hd/cloud/Tilman/Computer/selective-backups/daily/" +weekly_dir = "" +monthly_dir = "" + +basedir = "/media/hd/cloud/" +filelist = "/media/hd/cloud/Tilman/Computer/selective-backups/filelist.txt" +now = datetime.now() +date_time = now.strftime("%Y-%m-%d_") + +with open(filelist) as file: + lines = [line.rstrip() for line in file] + +for line in lines: + #f_basename = os.path.basename(line) + target_filename = date_time + line.replace("/","|") + ".tar.gz" + print(target_filename) + src_path = basedir + line + src_file = os.path.basename(src_path) + src_dir = os.path.dirname(src_path) + print(src_dir) + shutil.make_archive(daily_dir + target_filename, 'gztar', src_dir, src_file) + + +#os.path.basename +#shutil.make_archive(output_filename, 'zip', dir_name) \ No newline at end of file