File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 11import os
22import shutil
33
4+
45def automated_backup (source_dir , destination_dir ):
56 try :
67 # Check if the source directory exists
@@ -15,16 +16,19 @@ def automated_backup(source_dir, destination_dir):
1516 for root , dirs , files in os .walk (source_dir ):
1617 for file in files :
1718 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 ))
1921 shutil .copy2 (source_file , destination_file )
2022
2123 print ("Backup completed successfully!" )
2224 except Exception as e :
2325 print (f"An error occurred during backup: { e } " )
2426
27+
2528if __name__ == '__main__' :
2629 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: " )
2832
2933 automated_backup (source_directory , destination_directory )
3034 '''
You can’t perform that action at this time.
0 commit comments