slight changes to adapt to new place

This commit is contained in:
jenz
2023-06-14 23:45:48 +02:00
parent 73be3c4904
commit 8542e72a2c
4 changed files with 76 additions and 441 deletions
+10 -10
View File
@@ -50,11 +50,12 @@ class sftp_remote:
channel = self.ssh.get_transport().open_session(timeout=120)
#-T3= 3 threads, use 70% of available ram
#TODO exclude dir where hlstats spams pictures of the player graphs
if 'tar_recursive' == command_state:
exec_command_state = f"XZ_OPT='-T3 --memlimit-compress=70%' tar --exclude={zipname} -cJf {zipname} {self.path}"
exec_command_state = f"XZ_OPT='-T3 --memlimit-compress=70%' tar --exclude={zipname} --exclude=/home/nonroot/backups/ --exclude=/home/nonroot/demos --exclude=/home/nonroot/snap --exclude=logs/ --ignore-failed-read -cJf {zipname} {self.path}"
elif 'mysqldump' == command_state:
#check README for my.cnf regarding how this works
exec_command_state = f'mysqldump -u root --all-databases > mysqldump.sql'
exec_command_state = f'mysqldump -u backups_db --all-databases > mysqldump.sql'
else: #tar_mysqldump
exec_command_state = f"XZ_OPT='-T3 --memlimit-compress=70%' tar -cJf {zipname} /home/{self.username}/mysqldump.sql"
exec_cmd = f'cd /home/{self.username}/; {exec_command_state}'
@@ -187,14 +188,13 @@ class sftp_remote:
def delete_remote_zips(self, backups_dir):
self.connect()
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(".xz"):
continue
utime = self.sftp.stat(pathfile).st_mtime
last_modified = datetime.fromtimestamp(utime)
self.delete_file(last_modified, pathfile, 25)
for files in self.sftp.listdir(f'{backups_dir}'):
pathfile = f'{backups_dir}{files}'
if not pathfile.endswith(".xz"):
continue
utime = self.sftp.stat(pathfile).st_mtime
last_modified = datetime.fromtimestamp(utime)
self.delete_file(last_modified, pathfile, 40)
self.disconnect()
def delete_remote_zip_temp(self, zipname):