Automatic MySQL / PostgreSQL Backups with a Shell Script and Cron Job

preview_player
Показать описание
We'll cover backing things up on a custom schedule and restoring from a backup.

Hit the subscribe button to receive more videos like this!

---

Code:

Timestamps:

0:00 -- What we'll be covering in this video
0:44 -- Sendy is the app we're backing up, which uses MySQL / MariaDB
1:44 -- Using mysqldump to save a compressed version of the database backup
4:00 -- Parsing out DB credentials from a file using grep, cut and sed
8:20 -- Demonstrating how the backup script works when calling it manually
9:32 -- Scheduling the backup to happen once a day with a cron job
12:13 -- Creating a separate backup rotation cron job to delete old backups
14:20 -- Going over how mtime works and how to set a custom time for testing
16:23 -- Creating another script to restore your database
22:02 -- Modifying things for PostgreSQL
22:51 -- When disaster strikes it's nice to have scripts to help restore things quickly
23:30 -- Potentially modifying things to write to block storage or an S3 bucket

Reference links:

---

Follow along?

Рекомендации по теме
Комментарии
Автор

Great video as always! Thanks a lot! It would be nice to have in it a little section about backup behavior under the load (like tables locking, etc.).

nnutipa
Автор

thank you! will try this on a Shared Dreamhost instance on my custom app.

icxiii
Автор

Hello Nick,

How to call SQL file(PostGresql) from shell script ?
Could you please share a snippet for calling sql file from shell script.

Thanks & Regards
Raju

rajuponthapalli
Автор

HI @Nick Janetakis !!!! For (POSTGRES) I need to compress the archive log files (WAL files) in various location kindly and delete the older WAL files periodically... Kindly suggest a better way to compress it in corn job or in manual command...

If your willing kindly put a video belongs to this Postgres archive (compression)

and do more videos on Postgres DB

umarsharief
Автор

You look and sound just like Buster from Arrested Development lol

aaronpirc
welcome to shbcf.ru