It's easy to use plugin, but you only need few commands to run :D
Usually Wordpress user will just quickly find a plugin to backup the website and its databases. Is it to daunting to do it by ourselves?
![]() | |
Photo by Science in HD on Unsplash |
I find plugin is easy in certain way, but for an admin myself, i prefer simple command / script to get the job done.
Create database backup
This is the command required to run a simple database backup in mysql.p/s you can change the destination path. I put in /tmp because i want to upload to gdrive later.
root@foodah:/tmp# mysqldump -u root -p mydatabase > /tmp/mydatabase_backup_2020.sql |
If you choose to upload to Gdrive
Normally a user might just want to backup the file to its host server. For this case i wanted to upload the backup file(s) to Gdrive. And im using a third party Gdrive command client. You might want to checkout tutorial on how to get it installed in your server~ **Use at your own risk! the third party cli will have access and write permission to your Gdrive files!**
I running below command to push my sql backup file to Gdrive.
Example usage : gdrive push -destination (path on google drive) (path on local drive)
gdrive push -destination F_EOL/DATABASE mydatabase_backup_2020.sql |
You can verify that the file is uploaded successfully on Gdrive.
Why I backup to Gdrive?
One of the reason i want to share it around, have a secondary free cloud storage and I also want to reduce bandwidth usage of my internet. I'm using a mobile internet and really stingy about it. Thus using a server bandwidth is a better option to me. Why don't I push to Git? well that will be a better approach. But backing up the media files pushing to Git do no good.
Multiple revisions of large files increase the clone and fetch times for other users of a repository,
You can read more on this article from Git. I'll leave to expert to give thoughts on this. To be honest my website is not CI/CD compliant!
Next lets backup our Wordpress contents
First before we backup, probably we can remove any big log files. to reduced the backup size.
# Compressing file using Gz | |
tar -czvf mywebsite.tar.gz /var/www/mywebsite | |
# Compressing file using Zip (more Windows friendly) | |
zip -r mywebsite.zip /var/www/foodahlite |
Of course i will push it to Gdrive again!
gdrive push -destination F_EOL/WEBSITE mywebsite.* |
To see how to restore the Wordpress website and database check out my next post!
Comments
Post a Comment