Allow to disable mail backup
This commit is contained in:
@@ -126,6 +126,13 @@ Command::
|
||||
|
||||
This mode is the same as silent batch mode, but you provide the path to the backup directory you want.
|
||||
|
||||
|
||||
If you want to disable mail backup::
|
||||
|
||||
$ sudo ./run.py --backup --no-mail <your domain>
|
||||
|
||||
This can be useful for larger instance
|
||||
|
||||
Change the generated hostname
|
||||
-----------------------------
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ def install(appname, config, upgrade):
|
||||
utils.printcolor(u"{}".format(inst), utils.RED)
|
||||
sys.exit(1)
|
||||
|
||||
def backup(config, bashArg):
|
||||
def backup(config, bashArg, nomail):
|
||||
"""Backup instance"""
|
||||
try:
|
||||
script = importlib.import_module(
|
||||
@@ -32,7 +32,7 @@ def backup(config, bashArg):
|
||||
except ImportError:
|
||||
print("Error importing backup")
|
||||
try:
|
||||
getattr(script, "Backup")(config, bashArg).run()
|
||||
getattr(script, "Backup")(config, bashArg, nomail).run()
|
||||
except utils.FatalError as inst:
|
||||
utils.printcolor(u"{}".format(inst), utils.RED)
|
||||
sys.exit(1)
|
||||
|
||||
@@ -28,11 +28,11 @@ class Backup():
|
||||
#||--> mails
|
||||
# |--> vmails
|
||||
|
||||
def __init__(self, config, bashArg):
|
||||
def __init__(self, config, bashArg, nomail):
|
||||
self.config = config
|
||||
self.destinationPath = ""
|
||||
self.BACKUPDIRECTORY = ["mails/", "custom/", "databases/"]
|
||||
|
||||
self.nomail = nomail
|
||||
self.isBash = False
|
||||
self.bash = ""
|
||||
if bashArg != "NOBASH":
|
||||
@@ -113,6 +113,10 @@ class Backup():
|
||||
|
||||
def backupMails(self):
|
||||
|
||||
if self.nomail:
|
||||
utils.printcolor("Skipping mail backup, no-mail argument provided", utils.MAGENTA)
|
||||
return
|
||||
|
||||
utils.printcolor("Backing up mails", utils.MAGENTA)
|
||||
|
||||
home_path = self.config.get("dovecot", "home_dir")
|
||||
|
||||
7
run.py
7
run.py
@@ -86,6 +86,9 @@ def main(input_args):
|
||||
parser.add_argument(
|
||||
"--sbash", action="store_true", default=False,
|
||||
help="same as --bash but backup will be at /modoboa_backup/Backup_M_Y_d_H_M")
|
||||
parser.add_argument(
|
||||
"--no-mail", action="store_true", default=False,
|
||||
help="Disable mail backup (save space)")
|
||||
parser.add_argument("domain", type=str,
|
||||
help="The main domain of your future mail server")
|
||||
args = parser.parse_args(input_args)
|
||||
@@ -93,7 +96,7 @@ def main(input_args):
|
||||
if args.debug:
|
||||
utils.ENV["debug"] = True
|
||||
|
||||
if not args.backup and (args.bash != None or args.sbash):
|
||||
if not args.backup and (args.bash != None or args.sbash or args.no_mail):
|
||||
utils.printcolor("You provided --bash or --sbash without --backup, "
|
||||
"if you want to do a backup, please provide --backup!", utils.RED)
|
||||
return
|
||||
@@ -129,7 +132,7 @@ def main(input_args):
|
||||
bashArg = args.bash
|
||||
elif args.sbash:
|
||||
bashArg = "TRUE"
|
||||
scripts.backup(config, bashArg)
|
||||
scripts.backup(config, bashArg, args.no_mail)
|
||||
return
|
||||
else:
|
||||
installation_disclaimer(args, config)
|
||||
|
||||
Reference in New Issue
Block a user