File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 1+ # flake8: noqa F501
12import pathlib
23import shutil
34import tempfile
@@ -25,19 +26,21 @@ def database(self):
2526 """
2627 Backup the database.
2728 """
28-
29+
2930 db_config = config ("database.databases" )
3031 default = db_config .get ("default" )
3132 connection = db_config .get (default )
3233 driver = connection .get ("driver" )
3334
34- db_file_path = base_path ("{}.gz" .format ("database-" + str (datetime .timestamp (datetime .now ()))))
35+ db_file_path = base_path (
36+ "{}.gz" .format ("database-" + str (datetime .timestamp (datetime .now ())))
37+ )
3538
3639 if driver == "sqlite" :
3740 pass
3841 elif driver == "mysql" :
3942 command_str = f"mysqldump -u { connection .get ('user' )} -p{ connection .get ('password' )} { connection .get ('database' )} "
40-
43+
4144 elif driver == "postgres" :
4245 command_str = f"pg_dump -U{ connection .get ('user' )} -h{ connection .get ('host' )} -p{ connection .get ('port' )} -d{ connection .get ('database' )} "
4346
@@ -49,7 +52,7 @@ def database(self):
4952
5053 elif driver == "oracle" :
5154 command_str = f"sqlplus -S{ connection .get ('user' )} /{ connection .get ('password' )} @{ connection .get ('host' )} :{ connection .get ('port' )} /{ connection .get ('database' )} "
52-
55+
5356 if command_str :
5457 with gzip .open (db_file_path , "wb" ) as f :
5558 popen = subprocess .Popen (
@@ -59,7 +62,7 @@ def database(self):
5962 universal_newlines = True ,
6063 )
6164 for stdout_line in iter (popen .stdout .readline , "" ):
62- f .write (stdout_line .encode (' utf-8' ))
65+ f .write (stdout_line .encode (" utf-8" ))
6366 popen .stdout .close ()
6467 popen .wait ()
6568 return db_file_path
Original file line number Diff line number Diff line change 1+ # flake8: noqa F501
12"""Backup Settings"""
23
34from masonite .utils .location import base_path
1112|
1213"""
1314
14- FILENAME = "backup" # The filename of the backup file. (without the extension)
15- DIRECTORY = "backup" # storage/backup
15+ FILENAME = "backup" # The filename of the backup file. (without the extension)
16+ DIRECTORY = "backup" # storage/backup
1617SOURCE = {
1718 "root" : base_path (),
1819 "excludes" : [
You can’t perform that action at this time.
0 commit comments