1- import os
21import pathlib
32import shutil
43import tempfile
87from datetime import datetime
98from masonite .utils .location import base_path
109
11- class Backup :
1210
11+ class Backup :
1312 def __init__ (self , application ) -> None :
1413 self .app = application
1514 self .backup_config = config ("backup" )
@@ -30,26 +29,25 @@ def files(self):
3029 """
3130 Backup the files.
3231 """
33- filename = self .backup_config .get ("filename" , "backup" ) + "-" + str (datetime .timestamp (datetime .now ()))
34- # make_archive(filename, "zip", self.backup_config.get("source").get("includes"))
32+ filename = (
33+ self .backup_config .get ("filename" , "backup" )
34+ + "-"
35+ + str (datetime .timestamp (datetime .now ()))
36+ )
3537
3638 output_dir = base_path ("storage/backup" )
3739
3840 if not pathlib .Path (output_dir ).exists ():
3941 pathlib .Path (output_dir ).mkdir (parents = True , exist_ok = True )
4042
4143 path_to_archive = pathlib .Path (output_dir ).joinpath (filename )
42-
44+
4345 with tempfile .TemporaryDirectory () as tmp :
4446 shutil .copytree (
4547 self .backup_config .get ("source" ).get ("root" ),
46- pathlib .Path (tmp ).joinpath (' temporary_backup' ),
47- ignore = shutil .ignore_patterns (* self .backup_config .get ("source" ).get ("excludes" ))
48+ pathlib .Path (tmp ).joinpath (" temporary_backup" ),
49+ ignore = shutil .ignore_patterns (* self .backup_config .get ("source" ).get ("excludes" )),
4850 )
49-
50- with patch ('os.path.isfile' , side_effect = self .accept ):
51- make_archive (path_to_archive , "zip" , tmp )
52- print ("ok" )
53-
54- print ("final" )
5551
52+ with patch ("os.path.isfile" , side_effect = self .accept ):
53+ make_archive (path_to_archive , "zip" , tmp )
0 commit comments