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

Published: 15 August 2020
on channel: Nick Janetakis
19k
223

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:

(affiliate link)
(affiliate link and you get $100 in credits)


---

Follow along?

Personal Website:
Twitter:


Watch video Automatic MySQL / PostgreSQL Backups with a Shell Script and Cron Job online without registration, duration 25 minute 10 second in high hd quality. This video was added by user Nick Janetakis 15 August 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 19 thousand once and liked it 223 people.