mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-26 02:57:04 +00:00
backups: suppress all output except errors
This commit is contained in:
parent
e288d7730b
commit
89a46089ee
@ -224,9 +224,17 @@ def perform_backup(full_backup):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Stop services.
|
# Stop services.
|
||||||
shell('check_call', ["/usr/sbin/service", "php5-fpm", "stop"])
|
def service_command(service, command, quit=None):
|
||||||
shell('check_call', ["/usr/sbin/service", "postfix", "stop"])
|
# Execute silently, but if there is an error then display the output & exit.
|
||||||
shell('check_call', ["/usr/sbin/service", "dovecot", "stop"])
|
code, ret = shell('check_output', ["/usr/sbin/service", service, command], capture_stderr=True, trap=True)
|
||||||
|
if code != 0:
|
||||||
|
print(ret)
|
||||||
|
if quit:
|
||||||
|
sys.exit(code)
|
||||||
|
|
||||||
|
service_command("php5-fpm", "stop", quit=True)
|
||||||
|
service_command("postfix", "stop", quit=True)
|
||||||
|
service_command("dovecot", "stop", quit=True)
|
||||||
|
|
||||||
# Run a backup of STORAGE_ROOT (but excluding the backups themselves!).
|
# Run a backup of STORAGE_ROOT (but excluding the backups themselves!).
|
||||||
# --allow-source-mismatch is needed in case the box's hostname is changed
|
# --allow-source-mismatch is needed in case the box's hostname is changed
|
||||||
@ -235,6 +243,7 @@ def perform_backup(full_backup):
|
|||||||
shell('check_call', [
|
shell('check_call', [
|
||||||
"/usr/bin/duplicity",
|
"/usr/bin/duplicity",
|
||||||
"full" if full_backup else "incr",
|
"full" if full_backup else "incr",
|
||||||
|
"--verbosity", "warning", "--no-print-statistics",
|
||||||
"--archive-dir", backup_cache_dir,
|
"--archive-dir", backup_cache_dir,
|
||||||
"--exclude", backup_root,
|
"--exclude", backup_root,
|
||||||
"--volsize", "250",
|
"--volsize", "250",
|
||||||
@ -246,9 +255,9 @@ def perform_backup(full_backup):
|
|||||||
get_env(env))
|
get_env(env))
|
||||||
finally:
|
finally:
|
||||||
# Start services again.
|
# Start services again.
|
||||||
shell('check_call', ["/usr/sbin/service", "dovecot", "start"])
|
service_command("dovecot", "start", quit=False)
|
||||||
shell('check_call', ["/usr/sbin/service", "postfix", "start"])
|
service_command("postfix", "start", quit=False)
|
||||||
shell('check_call', ["/usr/sbin/service", "php5-fpm", "start"])
|
service_command("php5-fpm", "start", quit=False)
|
||||||
|
|
||||||
# Once the migrated backup is included in a new backup, it can be deleted.
|
# Once the migrated backup is included in a new backup, it can be deleted.
|
||||||
if os.path.isdir(migrated_unencrypted_backup_dir):
|
if os.path.isdir(migrated_unencrypted_backup_dir):
|
||||||
@ -260,6 +269,7 @@ def perform_backup(full_backup):
|
|||||||
"/usr/bin/duplicity",
|
"/usr/bin/duplicity",
|
||||||
"remove-older-than",
|
"remove-older-than",
|
||||||
"%dD" % config["min_age_in_days"],
|
"%dD" % config["min_age_in_days"],
|
||||||
|
"--verbosity", "error",
|
||||||
"--archive-dir", backup_cache_dir,
|
"--archive-dir", backup_cache_dir,
|
||||||
"--force",
|
"--force",
|
||||||
config["target"]
|
config["target"]
|
||||||
@ -274,6 +284,7 @@ def perform_backup(full_backup):
|
|||||||
shell('check_call', [
|
shell('check_call', [
|
||||||
"/usr/bin/duplicity",
|
"/usr/bin/duplicity",
|
||||||
"cleanup",
|
"cleanup",
|
||||||
|
"--verbosity", "error",
|
||||||
"--archive-dir", backup_cache_dir,
|
"--archive-dir", backup_cache_dir,
|
||||||
"--force",
|
"--force",
|
||||||
config["target"]
|
config["target"]
|
||||||
|
Loading…
Reference in New Issue
Block a user