Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
9ca116d5
Commit
9ca116d5
authored
Aug 09, 2015
by
Joshua Tauberer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add an option to disable backups
parent
cdd3a646
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
backup.py
management/backup.py
+10
-2
system-backup.html
management/templates/system-backup.html
+11
-4
No files found.
management/backup.py
View file @
9ca116d5
...
...
@@ -24,6 +24,10 @@ def backup_status(env):
config
=
get_backup_config
(
env
)
now
=
datetime
.
datetime
.
now
(
dateutil
.
tz
.
tzlocal
())
# Are backups dissbled?
if
config
[
"target"
]
==
"off"
:
return
{
}
backups
=
{
}
backup_cache_dir
=
os
.
path
.
join
(
backup_root
,
'cache'
)
...
...
@@ -174,6 +178,10 @@ def perform_backup(full_backup):
backup_cache_dir
=
os
.
path
.
join
(
backup_root
,
'cache'
)
backup_dir
=
os
.
path
.
join
(
backup_root
,
'encrypted'
)
# Are backups dissbled?
if
config
[
"target"
]
==
"off"
:
return
# In an older version of this script, duplicity was called
# such that it did not encrypt the backups it created (in
# backup/duplicity), and instead openssl was called separately
...
...
@@ -357,8 +365,8 @@ def backup_set_custom(env, target, target_user, target_pass, min_age):
# Validate.
try
:
if
config
[
"target"
]
!=
"local"
:
#
"local" is
n't supported by the following function, which expects a full url in the target key,
if
config
[
"target"
]
not
in
(
"off"
,
"local"
)
:
#
these are
n't supported by the following function, which expects a full url in the target key,
# which is what is there except when loading the config prior to saving
list_target_files
(
config
)
except
ValueError
as
e
:
...
...
management/templates/system-backup.html
View file @
9ca116d5
...
...
@@ -14,6 +14,7 @@
<label
for=
"backup-target-type"
class=
"col-sm-2 control-label"
>
Backup to:
</label>
<div
class=
"col-sm-2"
>
<select
class=
"form-control"
rows=
"1"
id=
"backup-target-type"
onchange=
"toggle_form()"
>
<option
value=
"off"
>
Nowhere (Disable Backups)
</option>
<option
value=
"local"
>
{{hostname}}
</option>
<option
value=
"s3"
>
Amazon S3
</option>
</select>
...
...
@@ -29,7 +30,7 @@
<div>
Backups are stored in an Amazon Web Services S3 bucket. You must have an AWS account already.
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group
backup-target-local backup-target-s3
"
>
<label
for=
"min-age"
class=
"col-sm-2 control-label"
>
How many days should backups be kept?
</label>
<div
class=
"col-sm-8"
>
<input
type=
"number"
class=
"form-control"
rows=
"1"
id=
"min-age"
>
...
...
@@ -122,7 +123,11 @@ function show_system_backup() {
$
(
'
#backup-status tbody
'
).
html
(
""
);
var
total_disk_size
=
0
;
if
(
r
.
backups
.
length
==
0
)
{
if
(
typeof
r
.
backups
==
"
undefined
"
)
{
var
tr
=
$
(
'
<tr><td colspan="3">Backups are turned off.</td></tr>
'
);
$
(
'
#backup-status tbody
'
).
append
(
tr
);
return
;
}
else
if
(
r
.
backups
.
length
==
0
)
{
var
tr
=
$
(
'
<tr><td colspan="3">No backups have been made yet.</td></tr>
'
);
$
(
'
#backup-status tbody
'
).
append
(
tr
);
}
...
...
@@ -157,6 +162,8 @@ function show_custom_backup() {
function
(
r
)
{
if
(
r
.
target
==
"
file://
"
+
r
.
file_target_directory
)
{
$
(
"
#backup-target-type
"
).
val
(
"
local
"
);
}
else
if
(
r
.
target
==
"
off
"
)
{
$
(
"
#backup-target-type
"
).
val
(
"
off
"
);
}
else
if
(
r
.
target
.
substring
(
0
,
5
)
==
"
s3://
"
)
{
$
(
"
#backup-target-type
"
).
val
(
"
s3
"
);
var
hostpath
=
r
.
target
.
substring
(
5
).
split
(
'
/
'
);
...
...
@@ -179,7 +186,7 @@ function set_custom_backup() {
var
target_pass
=
$
(
"
#backup-target-pass
"
).
val
();
var
target
;
if
(
target_type
==
"
local
"
)
if
(
target_type
==
"
local
"
||
target_type
==
"
off
"
)
target
=
target_type
;
else
if
(
target_type
==
"
s3
"
)
target
=
"
s3://
"
+
$
(
"
#backup-target-s3-host
"
).
val
()
+
"
/
"
+
$
(
"
#backup-target-s3-path
"
).
val
();
...
...
@@ -196,7 +203,7 @@ function set_custom_backup() {
},
function
(
r
)
{
// Responses are multiple lines of pre-formatted text.
show_modal_error
(
"
Backup configuration
"
,
$
(
"
<pre/>
"
).
text
(
r
)
);
show_modal_error
(
"
Backup configuration
"
,
$
(
"
<pre/>
"
).
text
(
r
)
,
function
()
{
show_system_backup
();
});
// refresh after modal
},
function
(
r
)
{
show_modal_error
(
"
Backup configuration (error)
"
,
r
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment