This is document deals with how to take backup of wordpress(wordpress backup script). The following scrip is daily backup script which deletes old 5 days backup. For wordpress we need to take backup of wordpress contents ( /var/www/html/) and database backup.
If your server crashed you can import these backup to a new machine where all the wordpress dependencies are installed.
Step 1: Create a backup script file.
Add the following lines
dayago=`(date –date=’05 days ago’ ‘+%Y-%m-%d’)`
zip -r html$todate.zip /var/www/html/
mysqldump -u$databaseuser -p$databasepassword $databasename > database-bk$todate.sql
rm -rf ../$dayago
save and exit
Step 2: Change the permission for this file
chmod a+x backup.sh
Step 3: Configure daily backup using cron.
Add the following line in crontab
0 0 * * * sh /root/backup.sh
Next restart the cron service
Thus you have completed the wordpress backup configuration. later you can upload the backuped files to a FTP server or any other storage location.
© 2018, Techrunnr. All rights reserved.