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