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
21 lines
608 B
from pathlib import Path
|
|
|
|
from paramiko.client import SSHClient
|
|
|
|
from openwrt_backup.utils import exec_remote
|
|
|
|
|
|
def make_backup_on_remote(client: SSHClient, tmp_path: Path):
|
|
cmdline = ["sysupgrade", "-b"]
|
|
remote_dest = tmp_path / "backup_latest.openwrt_backup.tar.gz"
|
|
cmdline.append(remote_dest)
|
|
stdout, stderr = exec_remote(client, cmdline)
|
|
stdout.read()
|
|
return remote_dest
|
|
|
|
|
|
def retrieve_backup_on_remote(client: SSHClient, src: Path, dest: Path):
|
|
sftp_client = client.open_sftp()
|
|
src, dest = map(str, (src, dest))
|
|
sftp_client.get(src, dest)
|
|
sftp_client.remove(src)
|