selective-backup.py

This commit is contained in:
2023-11-27 19:42:24 +01:00
parent 35faa3f4a3
commit f93f399dc9
+6 -3
View File
@@ -3,15 +3,20 @@ from zipfile import ZipFile
import os
import shutil
# base directory
basedir = "/media/hd/cloud"
# list of the paths to the files and directories to be copied, relative to the base directory
filelist = "/media/hd/cloud/Tilman/Computer/selective-backups/filelist.txt"
# duration for backups to be kept
days_to_keep = 5
months_to_keep = 5
# directories to backup to
daily_dir = "/media/hd/cloud/Tilman/Computer/selective-backups/daily/"
monthly_dir = "/media/hd/cloud/Tilman/Computer/selective-backups/monthly/"
basedir = "/media/hd/cloud"
now = datetime.now()
today = datetime.today()
target_filename = today.strftime('%Y-%m-%d') + "_selective-backup.zip"
@@ -19,8 +24,6 @@ target_filename = today.strftime('%Y-%m-%d') + "_selective-backup.zip"
with open(filelist) as file:
lines = [line.rstrip() for line in file]
#os.chdir(basedir)
# backup directories and files
with ZipFile(daily_dir + target_filename, 'w') as zip:
for line in lines: