Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions backup saver/backup_saver.py
Original file line number Diff line number Diff line change
@@ -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)


13 changes: 13 additions & 0 deletions backup saver/readme.md
Original file line number Diff line number Diff line change
@@ -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.