Python Prompts Free Prompt

Python Script to Automate Backing Up Database

Create a Python script to back up a PostgreSQL/MySQL database
☆ Save
Prompt
You are a Python developer. Write a script that dumps a database to a SQL file and optionally compresses it. The script must: 1) Accept database credentials (from env or config), 2) Use subprocess to call pg_dump or mysqldump, 3) Save backup with timestamp, 4) Compress with gzip, 5) Upload to cloud storage (S3, Google Drive) using APIs, 6) Keep only last N backups, 7) Log the process. Add error handling.

How to use this prompt

1
Click Copy Prompt above to copy to your clipboard.
2
Open ChatGPT, Claude, Gemini, or any AI assistant and paste the prompt.
3
Replace any [PLACEHOLDER] values with your specific details.
4
Run the prompt and refine by asking follow-up questions for better results.