qubes.backup
– Backup¶
-
exception
qubes.backup.
BackupCanceledError
(msg, tmpdir=None)[source]¶ Bases:
qubes.exc.QubesException
-
class
qubes.backup.
Backup
(app, vms_list=None, exclude_list=None, **kwargs)[source]¶ Bases:
object
Backup operation manager. Usage:
>>> app = qubes.Qubes() >>> # optional - you can use 'None' to use default list (based on >>> # vm.include_in_backups property) >>> vms = [app.domains[name] for name in ['my-vm1', 'my-vm2', 'my-vm3']] >>> exclude_vms = [] >>> options = { >>> 'compressed': True, >>> 'passphrase': 'This is very weak backup passphrase', >>> 'target_vm': app.domains['sys-usb'], >>> 'target_dir': '/media/disk', >>> } >>> backup_op = Backup(app, vms, exclude_vms, **options) >>> print(backup_op.get_backup_summary()) >>> asyncio.get_event_loop().run_until_complete(backup_op.backup_do())
See attributes of this object for all available options.
-
app
= None¶ application object
-
backup_id
= None¶ backup ID, needs to be unique (for a given user), not necessary unpredictable; automatically generated
-
chunk_size
= None¶ progress of the backup - bytes handled of the current VM
-
compressed
= None¶ should the backup be compressed?
-
compression_filter
= None¶ custom compression filter; a program which process stdin to stdout
-
passphrase
= None¶ what passphrase should be used to intergrity protect (and encrypt) the backup; required
-
progress_callback
= None¶ callback for progress reporting. Will be called with one argument - progress in percents
-
target_vm
= None¶ VM to which backup should be sent (if any)
-
tmpdir
= None¶ directory for temporary files - set after creating the directory
-
total_backup_bytes
= None¶ total backup size (set by
get_files_to_backup()
)
-
-
class
qubes.backup.
BackupHeader
(version=None, encrypted=None, compressed=None, compression_filter=None, hmac_algorithm=None, crypto_algorithm=None, backup_id=None)[source]¶ Bases:
object
Structure describing backup-header file included as the first file in backup archive
-
qubes.backup.
handle_streams
(stream_in, stream_out, size_limit=None, progress_callback=None)[source]¶ Copy stream_in to all streams_out and monitor all mentioned processes. If any of them terminate with non-zero code, interrupt the process. Copy at most size_limit data (if given).
Parameters: - stream_in – StreamReader object to read data from
- stream_out – StreamWriter object to write data to
- size_limit – int maximum data amount to process
- progress_callback – callable function to report progress, will be given copied data size (it should accumulate internally)
Returns: “size_limit” or None (no error)
-
qubes.backup.
launch_proc_with_pty
(args, stdin=None, stdout=None, stderr=None, echo=True)[source]¶ Similar to pty.fork, but handle stdin/stdout according to parameters instead of connecting to the pty
:return tuple (subprocess.Popen, pty_master)
-
qubes.backup.
launch_scrypt
(action, input_name, output_name, passphrase)[source]¶ Launch ‘scrypt’ process, pass passphrase to it and return subprocess.Popen object.
Parameters: - action – ‘enc’ or ‘dec’
- input_name – input path or ‘-’ for stdin
- output_name – output path or ‘-’ for stdout
- passphrase (bytes) – passphrase
Returns: subprocess.Popen object