From 948d74ec5d8684cf43ff22da3b22f98f3d438f73 Mon Sep 17 00:00:00 2001 From: jenz Date: Thu, 2 Mar 2023 12:47:57 +0100 Subject: [PATCH] fixes the check for deletion type as it is now .xz instead of .zip, reduces amount of days before deletion to 8. extended tar command to block most directories throwing permissions errors --- file_mover/remote_local_dir.py | 2 +- file_mover/remote_sftp.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/file_mover/remote_local_dir.py b/file_mover/remote_local_dir.py index cbe9e6d..6d20079 100755 --- a/file_mover/remote_local_dir.py +++ b/file_mover/remote_local_dir.py @@ -36,7 +36,7 @@ class local_dir_remote: source_files = self.list_dir(True) zipname = f'{job["zipname"]}-{str(datetime.now()).split(" ")[0]}.tar.xz' #-T3 = 3 threads, the backups are meant to run in the night at 5 am to not interfere with players. - exec_command_state = f"XZ_OPT='-T3 --memlimit-compress=70%' tar -cJf {zipname} {self.path}" + exec_command_state = f"XZ_OPT='-T3 --memlimit-compress=70%' tar --exclude='/home/gameservers/.python_history' --exclude='/home/gameservers/.cache' --exclude='/home/gameservers/css_mg/cstrike/demos' --exclude='/home/gameservers/css_mg/cstrike/download' --exclude='/home/gameservers/css_mg/cstrike/addons/sourcemod/data' --exclude='/home/gameservers/css_jb/cstrike/logs' --exclude='/home/gameservers/css_jb/cstrike/download' --exclude='/home/gameservers/css_jb/cstrike/downloadlists' --exclude='/home/gameservers/css_ze/cstrike/download' --exclude='/home/gameservers/css_2_ze/cstrike/download' --exclude='/home/gameservers/css_dev/cstrike/download' --exclude='/home/gameservers/css_2_ze/cstrike/addons/sourcemod/data' --exclude='/home/gameservers/svencoop/svencoop/logs' --exclude='/home/gameservers/css_gg/cstrike/logs' --exclude='/home/gameservers/css_gg/cstrike/download' --exclude='/home/gameservers/css_gg/cstrike/downloadlists' --exclude='/home/gameservers/css_mg_dev/cstrike/demos' --exclude='/home/gameservers/css_mg_dev/cstrike/download' --exclude='/home/gameservers/css_zr/cstrike/download' -cJf {zipname} {self.path}" print("exec_command_state: ", exec_command_state) subprocess.run([exec_command_state], shell=True) diff --git a/file_mover/remote_sftp.py b/file_mover/remote_sftp.py index 39482b9..25bde38 100755 --- a/file_mover/remote_sftp.py +++ b/file_mover/remote_sftp.py @@ -190,11 +190,11 @@ class sftp_remote: for directories in self.sftp.listdir(backups_dir): for files in self.sftp.listdir(f'{backups_dir}/{directories}'): pathfile = f'{backups_dir}/{directories}/{files}' - if not pathfile.endswith(".zip"): + if not pathfile.endswith(".xz"): continue utime = self.sftp.stat(pathfile).st_mtime last_modified = datetime.fromtimestamp(utime) - self.delete_file(last_modified, pathfile, 10) + self.delete_file(last_modified, pathfile, 8) self.disconnect() def delete_remote_zip_temp(self, zipname):