Commit dbf47291 authored by Joshua Tauberer's avatar Joshua Tauberer

add management/backup.py --restore

parent 86b9ef49
...@@ -26,6 +26,7 @@ System: ...@@ -26,6 +26,7 @@ System:
* Z-Push (Exchange/ActiveSync) logs now exclude warnings and are now rotated to save disk space. * Z-Push (Exchange/ActiveSync) logs now exclude warnings and are now rotated to save disk space.
* Fix pip command that might have not installed all necessary Python packages. * Fix pip command that might have not installed all necessary Python packages.
* The control panel and backup would not work on Google Compute Engine because they install a conflicting boto package. * The control panel and backup would not work on Google Compute Engine because they install a conflicting boto package.
* Added a new command `management/backup.py --restore` to restore files from a backup to a target directory (command line arguments are passed to `duplicity restore`).
v0.14 (November 4, 2015) v0.14 (November 4, 2015)
------------------------ ------------------------
......
...@@ -314,6 +314,18 @@ def run_duplicity_verification(): ...@@ -314,6 +314,18 @@ def run_duplicity_verification():
env["STORAGE_ROOT"], env["STORAGE_ROOT"],
], get_env(env)) ], get_env(env))
def run_duplicity_restore(args):
env = load_environment()
config = get_backup_config(env)
backup_cache_dir = os.path.join(env["STORAGE_ROOT"], 'backup', 'cache')
shell('check_call', [
"/usr/bin/duplicity",
"restore",
"--archive-dir", backup_cache_dir,
config["target"],
] + args,
get_env(env))
def list_target_files(config): def list_target_files(config):
import urllib.parse import urllib.parse
try: try:
...@@ -443,6 +455,11 @@ if __name__ == "__main__": ...@@ -443,6 +455,11 @@ if __name__ == "__main__":
ret = backup_status(load_environment()) ret = backup_status(load_environment())
print(rtyaml.dump(ret["backups"])) print(rtyaml.dump(ret["backups"]))
elif len(sys.argv) >= 2 and sys.argv[1] == "--restore":
# Run duplicity restore. Rest of command line passed as arguments
# to duplicity. The restore path should be specified.
run_duplicity_restore(sys.argv[2:])
else: else:
# Perform a backup. Add --full to force a full backup rather than # Perform a backup. Add --full to force a full backup rather than
# possibly performing an incremental backup. # possibly performing an incremental backup.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment