Browse Source

working on a working version

master
Holger Frey 5 years ago
parent
commit
960685e736
  1. 27
      zfs-snapshot-backup.py

27
zfs-snapshot-backup.py

@ -96,24 +96,24 @@ def backup_latest_snapshot(member, elab_snapshots, existing_backups):
# create the backup # create the backup
print(" - generating temporary backup file") print(" - generating temporary backup file")
tmp_gzip_filepath = gzip_filepath(current_snapshot) #tmp_gzip_filepath = gzip_filepath(current_snapshot)
with open(tmp_gzip_filepath, "wb") as file_handle: #with open(tmp_gzip_filepath, "wb") as file_handle:
gzip_in = subprocess.Popen( # gzip_in = subprocess.Popen(
"gzip", stdin=subprocess.PIPE, stdout=file_handle, check=True # "gzip", stdin=subprocess.PIPE, stdout=file_handle, check=True
).stdin # ).stdin
subprocess.call(send_cmd, stdout=gzip_in, check=True) # subprocess.call(send_cmd, stdout=gzip_in, check=True)
# copy the backup to the remote server # copy the backup to the remote server
print(" - copying temporary backup file") print(" - copying temporary backup file")
remote_url = ( #remote_url = (
f"{SSH_REMOTE}:~/{REMOTE_PATH}/{member}/{tmp_gzip_filepath.name}" # f"{SSH_REMOTE}:~/{REMOTE_PATH}/{member}/{tmp_gzip_filepath.name}"
) #)
copy_cmd = ["scp", "-i", SSH_KEY_FILE, str(tmp_gzip_filepath), remote_url] #copy_cmd = ["scp", "-i", SSH_KEY_FILE, str(tmp_gzip_filepath), remote_url]
call(copy_cmd) #call(copy_cmd)
# remove the temporary file # remove the temporary file
print(" - removing temporary backup file") print(" - removing temporary backup file")
tmp_gzip_filepath.unlink() #tmp_gzip_filepath.unlink()
def create_backups(): def create_backups():
@ -125,5 +125,4 @@ def create_backups():
if __name__ == "__main__": if __name__ == "__main__":
es = elab_snapshots() create_backups()
print(list_remote_backups(es.keys()))

Loading…
Cancel
Save