• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

How to make a backup of website files & MySQL databases cron task

W

willgnosis

Guest
OK.. I wanted to write this because it has just taken me about 2 weeks of searching the net and trial and error to finally get a backup how i wanted.

In case you didn't know.. when you use the Plesk Backup Scheduer, it creates a file that apparently only Linux can unpack and is basically useless if you want to ever open the files on a pc.

So if, like me, you just want to be able to make a regular backup of your webisite files and it's databases you can do it like this:

First:

log into FTP using root user and go to the path /
Make a new folder called backup
make sure it has permissions set to 777
(most FTP programs you can right click the folder and choose 'file attributes' and set it to 777)

Next:

Login to Plesk
> Click Server on the left panel
> Click Scheduled Tasks
> Select the Root user
> Add New Task

Minute: 01 ( this means 01 minutes past the hour)
Hour: 02 (This means 02:00 AM)
Day of Month: * (This means every day)
Month: * (This means every Month)
Day of the Week : * ( This means every day)

Then for the command:

mysqldump --user=admin --password=youradminpassword --all-databases > /backup/mysqlall-`/bin/date +\%Y\%m\%d`.sql

That's for the database backup - This backs up ALL MySQL databases - for every website.

Now repeat and make another Scheduled task to backup all the web files for a certain domain:

You need this command:

tar -cvzf /backup/mywebsite.com-backup-`/bin/date +\%Y\%m\%d`.tar /var/www/vhosts/mywebsite.com/httpdocs

and finally

make a 3rd task that runs this command:

find /backup -mtime +5 -exec rm {} \;

This will delete any files older than 5 days.

Voila! A PROPER backup!

Oh yeah... if you try and put these together into a script file and try to cron run that... it doesn't work. no idea why.

This would have saved me 2 weeks!!!!
So Please don't remove it!

Will
 
Hi willgnosis,

When saving all databases in one dump file, how is the process of restoring only one database from that dump file?
 
Thank you will for sharing this. it helped me a lot and saved my time.
 
First:

log into FTP using root user and go to the path /
Make a new folder called backup
make sure it has permissions set to 777
(most FTP programs you can right click the folder and choose 'file attributes' and set it to 777)

Next:

Login to Plesk
> Click Server on the left panel
> Click Scheduled Tasks
> Select the Root user
> Add New Task

Minute: 01 ( this means 01 minutes past the hour)
Hour: 02 (This means 02:00 AM)
Day of Month: * (This means every day)
Month: * (This means every Month)
Day of the Week : * ( This means every day)

Then for the command:

mysqldump --user=admin --password=youradminpassword --all-databases > /backup/mysqlall-`/bin/date +\%Y\%m\%d`.sql

That's for the database backup - This backs up ALL MySQL databases - for every website.

Now repeat and make another Scheduled task to backup all the web files for a certain domain:

You need this command:

tar -cvzf /backup/mywebsite.com-backup-`/bin/date +\%Y\%m\%d`.tar /var/www/vhosts/mywebsite.com/httpdocs

and finally

make a 3rd task that runs this command:

find /backup -mtime +5 -exec rm {} \;

This will delete any files older than 5 days.

Ok, I cant seem to get any of the above to work, also I cant find where I check to see if the log error is being emailed to me!!

My site got hacked last week and I would really like to get this working so I have a contingency plan if it happens again..

Any help would be much appreciated!!
 
Really, no help what so ever!!

I would really appreciate some to fix the log error not being emailed to me!!
 
here is the trick, put /var/www/vhosts/mywebsite.com path before every path:


mysqldump --user=admin --password=youradminpassword --all-databases > /var/www/vhosts/mywebsite.com/backup/mysqlall-`/bin/date +\%Y\%m\%d`.sql

tar -cvzf /backup/mywebsite.com-backup-`/bin/date +\%Y\%m\%d`.tar /var/www/vhosts/mywebsite.com/httpdocs

/bin/find /var/www/vhosts/mywebsite.com/backup -mtime +5 -exec rm {} \;


this works for me
 
Last edited:
Back
Top