Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-mysqlbackend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-mysqlbackend
Commits
3a51a628
Commit
3a51a628
authored
5 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: changed backup.py to local execution
parent
1140452a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backup.py
+74
-0
74 additions, 0 deletions
backup.py
with
74 additions
and
0 deletions
backup.py
0 → 100755
+
74
−
0
View file @
3a51a628
#!/usr/bin/env python3
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2020 Daniel Hornung (d.hornung@indiscale.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# ** end header
"""
Remote module to create an SQL dump.
"""
import
argparse
import
os
import
subprocess
import
tempfile
def
create_dump
(
directory
=
None
):
"""
Create the SQL dump
Parameters via `args` (a dict)
------------------------------
dictionary : str
If not None, the place to write the SQL dump into.
Returns
-------
out : str
A YAML text representation of the backup process.
"""
command
=
[
"
./backup.sh
"
]
env
=
os
.
environ
.
copy
()
if
not
directory
:
os
.
makedirs
(
"
/tmp/caosdb/tmpfiles/backup/
"
,
exist_ok
=
True
)
directory
=
tempfile
.
mkdtemp
(
dir
=
"
/tmp/caosdb/tmpfiles/backup/
"
,
prefix
=
"
backup.
"
)
command
.
append
(
"
--backupdir={}
"
.
format
(
directory
))
result
=
subprocess
.
run
(
command
,
cwd
=
os
.
path
.
dirname
(
__file__
),
env
=
env
)
def
parse_args
():
"""
Parse the command line arguments.
"""
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
,
prog
=
"
mysql backup
"
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
)
parser
.
add_argument
(
'
-d
'
,
"
--directory
"
,
help
=
'
Directory to which the sql dump will be saved.
'
)
return
parser
.
parse_args
()
if
__name__
==
"
__main__
"
:
"""
The main function.
"""
args
=
parse_args
()
create_dump
(
args
.
directory
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment