File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import shutil
3
3
4
+
4
5
def automated_backup (source_dir , destination_dir ):
5
6
try :
6
7
# Check if the source directory exists
@@ -15,16 +16,19 @@ def automated_backup(source_dir, destination_dir):
15
16
for root , dirs , files in os .walk (source_dir ):
16
17
for file in files :
17
18
source_file = os .path .join (root , file )
18
- destination_file = os .path .join (destination_dir , os .path .relpath (source_file , source_dir ))
19
+ destination_file = os .path .join (
20
+ destination_dir , os .path .relpath (source_file , source_dir ))
19
21
shutil .copy2 (source_file , destination_file )
20
22
21
23
print ("Backup completed successfully!" )
22
24
except Exception as e :
23
25
print (f"An error occurred during backup: { e } " )
24
26
27
+
25
28
if __name__ == '__main__' :
26
29
source_directory = input ("Enter the source directory to be backed up: " )
27
- destination_directory = input ("Enter the destination directory for the backup: " )
30
+ destination_directory = input (
31
+ "Enter the destination directory for the backup: " )
28
32
29
33
automated_backup (source_directory , destination_directory )
30
34
'''
You can’t perform that action at this time.
0 commit comments