From 7e7af72c608ce6990382ea2ebc4a8dcc9c87ef71 Mon Sep 17 00:00:00 2001 From: krish Date: Sat, 23 May 2026 17:17:51 +0200 Subject: [PATCH 1/7] Add backup function to copy files with error handling --- backup saver | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 backup saver diff --git a/backup saver b/backup saver new file mode 100644 index 00000000..dd3c152d --- /dev/null +++ b/backup saver @@ -0,0 +1,24 @@ +import os +import shutil +def backup(source,destination): + if( os.path.exists(source)): + print("the file has been found") + else: + raise FileNotFoundError() + + if (os.path.exists(destination)): + print("the directory exists") + else: + os.mkdir(destination) + + try: + shutil.copy2(source,destination) + print("file copied successfully") + except Exception as e: + print(f"error during backup {e}") + +source1=input("Enter the path of the file you want to save") +destination1=input("Enter the destination directory for the backup") +backup(source1,destination1) + + From af21a4e499a628c8a5129b90741541af57ebfb28 Mon Sep 17 00:00:00 2001 From: krish Date: Sat, 23 May 2026 17:18:30 +0200 Subject: [PATCH 2/7] Rename backup saver to backup_saver.py --- backup saver => backup_saver.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename backup saver => backup_saver.py (100%) diff --git a/backup saver b/backup_saver.py similarity index 100% rename from backup saver rename to backup_saver.py From d3eedc5bd1cce8cc2b08ee5f7a78a79998f14763 Mon Sep 17 00:00:00 2001 From: krish Date: Sat, 23 May 2026 17:21:36 +0200 Subject: [PATCH 3/7] Delete backup_saver.py --- backup_saver.py | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 backup_saver.py diff --git a/backup_saver.py b/backup_saver.py deleted file mode 100644 index dd3c152d..00000000 --- a/backup_saver.py +++ /dev/null @@ -1,24 +0,0 @@ -import os -import shutil -def backup(source,destination): - if( os.path.exists(source)): - print("the file has been found") - else: - raise FileNotFoundError() - - if (os.path.exists(destination)): - print("the directory exists") - else: - os.mkdir(destination) - - try: - shutil.copy2(source,destination) - print("file copied successfully") - except Exception as e: - print(f"error during backup {e}") - -source1=input("Enter the path of the file you want to save") -destination1=input("Enter the destination directory for the backup") -backup(source1,destination1) - - From 4aee8b7cfb661702cf7643d1500ffd35e56c2508 Mon Sep 17 00:00:00 2001 From: krish Date: Sat, 23 May 2026 17:25:44 +0200 Subject: [PATCH 4/7] backup_saver.py --- backup saver/backup_saver.py/readme.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 backup saver/backup_saver.py/readme.md diff --git a/backup saver/backup_saver.py/readme.md b/backup saver/backup_saver.py/readme.md new file mode 100644 index 00000000..2fe3e1e9 --- /dev/null +++ b/backup saver/backup_saver.py/readme.md @@ -0,0 +1,13 @@ +# 📂 Python File Backup + +Backup files using Python's built-in `os` and `shutil`. + +## ✨ Features +* **Auto-Folder:** Creates the backup directory if missing. +* **Metadata:** Keeps original file dates intact using `shutil.copy2`. +* **Validation:** Checks if the source file exists. + +## 🚀 How to Use +1. Run: `python backup_script.py` +2. Enter the source path. +3. Enter the destination path. From abeb7e9be12558a3e20356662d244025500af720 Mon Sep 17 00:00:00 2001 From: krish Date: Sat, 23 May 2026 17:26:52 +0200 Subject: [PATCH 5/7] Delete backup saver/backup_saver.py directory --- backup saver/backup_saver.py/readme.md | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 backup saver/backup_saver.py/readme.md diff --git a/backup saver/backup_saver.py/readme.md b/backup saver/backup_saver.py/readme.md deleted file mode 100644 index 2fe3e1e9..00000000 --- a/backup saver/backup_saver.py/readme.md +++ /dev/null @@ -1,13 +0,0 @@ -# 📂 Python File Backup - -Backup files using Python's built-in `os` and `shutil`. - -## ✨ Features -* **Auto-Folder:** Creates the backup directory if missing. -* **Metadata:** Keeps original file dates intact using `shutil.copy2`. -* **Validation:** Checks if the source file exists. - -## 🚀 How to Use -1. Run: `python backup_script.py` -2. Enter the source path. -3. Enter the destination path. From 0f10fc6d615fdb712e525274565f760b87eb9b4d Mon Sep 17 00:00:00 2001 From: krish Date: Sat, 23 May 2026 17:27:24 +0200 Subject: [PATCH 6/7] Add README for Python File Backup project --- backup saver/readme.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 backup saver/readme.md diff --git a/backup saver/readme.md b/backup saver/readme.md new file mode 100644 index 00000000..2fe3e1e9 --- /dev/null +++ b/backup saver/readme.md @@ -0,0 +1,13 @@ +# 📂 Python File Backup + +Backup files using Python's built-in `os` and `shutil`. + +## ✨ Features +* **Auto-Folder:** Creates the backup directory if missing. +* **Metadata:** Keeps original file dates intact using `shutil.copy2`. +* **Validation:** Checks if the source file exists. + +## 🚀 How to Use +1. Run: `python backup_script.py` +2. Enter the source path. +3. Enter the destination path. From 6e1cbf04d99716d7c2c665310ae44136c28140bb Mon Sep 17 00:00:00 2001 From: krish Date: Sat, 23 May 2026 17:28:03 +0200 Subject: [PATCH 7/7] backup_saver.py --- backup saver/backup_saver.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 backup saver/backup_saver.py diff --git a/backup saver/backup_saver.py b/backup saver/backup_saver.py new file mode 100644 index 00000000..dd3c152d --- /dev/null +++ b/backup saver/backup_saver.py @@ -0,0 +1,24 @@ +import os +import shutil +def backup(source,destination): + if( os.path.exists(source)): + print("the file has been found") + else: + raise FileNotFoundError() + + if (os.path.exists(destination)): + print("the directory exists") + else: + os.mkdir(destination) + + try: + shutil.copy2(source,destination) + print("file copied successfully") + except Exception as e: + print(f"error during backup {e}") + +source1=input("Enter the path of the file you want to save") +destination1=input("Enter the destination directory for the backup") +backup(source1,destination1) + +