Skip to content
-
Subscribe to our newsletter & never miss our best posts. Subscribe Now!
The Server Admin
The Server Admin
  • Home
  • Linux
  • Windows
  • About
  • What Powers The Server Admin
  • Home
  • Linux
  • Windows
  • About
  • What Powers The Server Admin
Close

Search

  • https://www.facebook.com/
  • https://twitter.com/
  • https://t.me/
  • https://www.instagram.com/
  • https://youtube.com/
Subscribe
Linux

Backup Your Databases

By Anthony
March 24, 2024 2 Min Read
0

You have backups right? Of coarse you do, but you know what its always a good thing to double check yoru backups right now you know just to make sure.

So now that your back, lets talk about a simple but effective way to create, and backup your databases, lets dive on it!

** This is not the end all be all, but one way that I personally use that has always done me well.

I am going to assume the following two items. 1. Your already SSH’d into your vps, and 2 you already have your site online and ready to go. Now we just need to get it all ready for the world!

So were going to use the WordOps demo I setup over here.

So first thing were going to need to do is get the database credentials from our site. So head over to your site and open up your wp-config.php file.

Now lets grab the DB_NAME, DB_USER, and DB_PASSWORD data and copy them over to your notepad.

Now MySQL has a built in export tool that is very easy to us too, so let check this, first create a folder called backups and then a folder called mysql inside of it.

mkdir -p /backups/mysql

Now we can run the simple command mysqldump by using the following.

mysqldump your_db_name > "$(date +%F).what_have_you".sql

So you can see that a sql backup file was created., and that is it! So lets automate this so it runs everyday at X date and time.

Lets create a simple backup script. Open up your editor of choice, mine is nano.

nano /root/backup.sh

Paste into the file the following.

#!/bin/bash

################################################################

cd /backups/mysql && mysqldump wordpress_theserveradmin_com_jnTlEiP1 > "$(date +%F).wordpress.theserveradmin".sql

Now make the script executable.

chmod +x /root/backup.sh

Now run the script to make sure.

cd /root
./backup.sh

So awesome, now how do we automate this? With cron of coarse!

** Great Read on CronJobs and how to set them.

Now lets edit the crontab and paste our command into it.

nano /etc/crontab

Paste the following to the end of the file: 0 0 * * * root /root/backup.sh 2>&1

Now restart your crond and then you should be good to go for the first part of the backup!

Author

Anthony

Follow Me
Other Articles
Previous

WordOps

Next

Windows Server Converting Eval Version to Standard for activation

No Comment! Be the first one.

Leave a Reply

You must be logged in to post a comment.

Search

Need a Virtual Server for sysctl testing? Check out our plans!

Popular Posts

  • Mount sFTP folder as local drive
    by Anthony
    June 9, 2026
  • Robocopy Examples
    by Anthony
    February 12, 2026
  • Rsync Command Examples
    by Anthony
    February 10, 2026

Trending

  • Mount sFTP folder as local drive
    by Anthony
    June 9, 2026
  • Adding a GUI to a Server or VPS
    by Anthony
    August 27, 2024
  • Back up to a shared folder with Time Machine on Mac
    by Anthony
    January 4, 2025
  • Backup Your Databases
    by Anthony
    March 24, 2024

Editors Picks

    Send an email:
    mail@example.com

    Call me:
    123-456-7890

    • Facebook
    • Twitter
    • Instagram
    • TikTok
    • LinkedIn
    • Behance
    Copyright 2026 — The Server Admin. All rights reserved. Blogsy WordPress Theme