You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
608 B

5 years ago
  1. from pathlib import Path
  2. from paramiko.client import SSHClient
  3. from openwrt_backup.utils import exec_remote
  4. def make_backup_on_remote(client: SSHClient, tmp_path: Path):
  5. cmdline = ["sysupgrade", "-b"]
  6. remote_dest = tmp_path / "backup_latest.openwrt_backup.tar.gz"
  7. cmdline.append(remote_dest)
  8. stdout, stderr = exec_remote(client, cmdline)
  9. stdout.read()
  10. return remote_dest
  11. def retrieve_backup_on_remote(client: SSHClient, src: Path, dest: Path):
  12. sftp_client = client.open_sftp()
  13. src, dest = map(str, (src, dest))
  14. sftp_client.get(src, dest)
  15. sftp_client.remove(src)