Help - Search - Members - Calendar
Full Version: How to use the plesk backup utilities for running regulary scheduled backups
The Planet Forums > Control Panels > Plesk > Plesk HOWTOs
Pages: 1, 2
NightHawk
Ok...I have been asked a few time for a quick and dirty how-to on setting up the
plesk backup utilities for running regulary scheduled backups..

So, here is a very quick and very dirty how-to.

Pre-requisites
1) Plesk Server Administator 5.0.0 or above
2) RedHat 7.1 or above
3) Plesk Backup Utilities installed (you can get these at: https://www.plesk.com/Downloads/utilities.php)


Ok, the rest is simple, just pick the file below that matches your needs and throw it in a cron.
I recommend cron.daily, but adjust as needed to fit your taste.

Each of these will keep 3 backups and rotate them accordingly.
Directory Dump1 will be the most current, and Dump3 the least current backup.

**note: I am using --nostop --tar-ignore-failed-read, which means these may not be 100% complete backups.**
**If you need a one-shot backup becuase you are de-installing plesk run the commmands without those tags.**


1) login to your server via ssh..and su - to root.
2) cd /etc/cron.daily
3) vi zzbackup.sh
4) enter insert mode (i) paste in whichever one of the below match your requirements.
5) exit vi ( icon_mad.gif )
6) chmod 755 /etc/cron.daily/zzbackup.sh

[PHP]
#####
###local backups
###put this script in cron.daily
#####
#!/bin/bash
/bin/rm -Rf /dump3
/bin/mv /dump2 /dump3
/bin/mv /dump1 /dump2
/bin/mkdir /dump1
cd /dump1
/usr/local/psa/bin/psadump -F -f - --nostop --tar-ignore-failed-read | split -b 1000m - dump.
####################################
###end of include###################
####################################
[/PHP]

[PHP]
#####
###local backups with gzip
###put this script in cron.daily
#####
#!/bin/bash
/bin/rm -Rf /dump3
/bin/mv /dump2 /dump3
/bin/mv /dump1 /dump2
/bin/mkdir /dump1
cd /dump1
/usr/local/psa/bin/psadump -F -f - --nostop --tar-ignore-failed-read | gzip | split -b 1000m - dump.

####################################
###end of include###################
####################################
[/PHP]

[PHP]
#####
###local backups on a box with 2 HD's
###put this script in cron.dail
###must have 2nd HD mounted as /home2 for this to work
#####
#!/bin/bash
/bin/rm -Rf /home2/dump3
/bin/mv /home2/dump2 /home2/dump3
/bin/mv /home2/dump1 /home2/dump2
/bin/mkdir /home2/dump1
cd /home2/dump1
/usr/local/psa/bin/psadump -F -f - --nostop --tar-ignore-failed-read | split -b 1000m - dump.

####################################
###end of include###################
####################################
[/PHP]

[PHP]
#####
###local backups on a box with 2 HD's
###put this script in cron.daily
###must have 2nd HD mounted as /home2 for this to work
#####
#!/bin/bash
/bin/rm -Rf /home2/dump3
/bin/mv /home2/dump2 /home2/dump3
/bin/mv /home2/dump1 /home2/dump2
/bin/mkdir /home2/dump1
cd /home2/dump1
/usr/local/psa/bin/psadump -F -f - --nostop --tar-ignore-failed-read | gzip | split -b 1000m - dump.

####################################
###end of include###################
####################################[/PHP]
NightHawk
To restore the backups, if needed, use the following block that matches your needs.
You will have to edit the map_file and possibly the shells_map_file if you are not restoring on the box your pulled the backup from.

(the directories used in these restores are the defualt ones..be sure to change /psadumps to the path to the directory that holds the backups you want to restore)

[PHP]
#####
###restore procedure
### for gzip backups
#####
cd /psadumps
cat dump.* | gzip -d | /usr/local/psa/bin/psarestore -m map_file -s shells_map_file -f -
vi map_file
vi shells_map_file
cat dump.* | gzip -d | /usr/local/psa/bin/psarestore -m map_file -s shells_map_file -f -
####################################
###end of include###################
####################################
[/PHP]


[PHP]
#####
###restore procedure
###for non-gzip backups
#####
cd /psadumps
cat dump.* | /usr/local/psa/bin/psarestore -m map_file -s shells_map_file -f -
vi map_file
vi shells_map_file
cat dump.* | /usr/local/psa/bin/psarestore -m map_file -s shells_map_file -f -
####################################
###end of include###################
####################################
[/PHP]
GlobalPN
RPM 5.0.5 allready contains the backup utility along with it correct? I've been told this by RackShack people and would just like to clarify it once again. Thanks NightHawk you saved us all icon_smile.gif.
NightHawk
QUOTE
Originally posted by GlobalPN
RPM 5.0.5 allready contains the backup utility along with it correct? I've been told this by RackShack people and would just like to clarify it once again. Thanks NightHawk you saved us all icon_smile.gif.


as far as I know....unless RS has added them to thier image (which is possible) you have to install the plesk backup utitlities yourself.
GlobalPN
ok, is there a tutorial on how to install this using ssh? Also how would I delete the current one I made?
NightHawk
QUOTE
Originally posted by GlobalPN
ok, is there a tutorial on how to install this using ssh? Also how would I delete the current one I made?


all of the above is done via ssh. I have not put together a how-to for installing the actual plesk backup utilites, but that is becuase they are extemely self-explanitory, just go download them to the server (wget) for plesk, unpack the tar.gz...and run the .sh that comes with it....they come with a .txt file that explains all of that.
GlobalPN
How do you exit the vi? I have tried to do this but have not been successful. Thanks for your help with everything.
Gentle Giant
Thanks for this - getting a message when running that says...

Some errors can be occured during restoration hosting directories or mailnames because --tar-ignore-failed_read and --nostop keys was used at the same time.

Anything to be concerned about?
Gentle Giant
Also (unless I am being thick!)

In the restore you say

cd /pasdumps

I assume you mean

cd /psadumps

yet in the original backup the dumps are done to the root in /dump1 /dump2 /dump3

Just wondering if we have the odd typo.

Take care.
NightHawk
QUOTE
Originally posted by GlobalPN
How do you exit the vi? I have tried to do this but have not been successful. Thanks for your help with everything.


:q <--- quit
:q! <--- quit without saving after making changes
icon_mad.gif <--- quit and save
NightHawk
QUOTE
Originally posted by Gentle Giant
Thanks for this - getting a message when running that says...

Some errors can be occured during restoration hosting directories or mailnames because --tar-ignore-failed_read and --nostop keys was used at the same time.

Anything to be concerned about?


Only worry about this..if you are using this for a one shot backup...and restoring your server.....

the --nostop makes it to where the servers services (apache, psa, etc) don't stop during backup...this can cause some corrupted files, but if you are running it daily like I set this up for..you won't want all your services stopping all time...and odds are...any messed up files would be in another backup..
NightHawk
QUOTE
Originally posted by Gentle Giant
Also (unless I am being thick!)

In the restore you say  

cd /pasdumps

I assume you mean

cd /psadumps

yet in the original backup the dumps are done to the root in /dump1 /dump2 /dump3

Just wondering if we have the odd typo.

Take care.


Hrm...I don't see what you are talking about cool.gif

(ahh..the edit button is a good thing...thanks for pointing that out)
nacarls
I get this error when trying to restore. The sites were backed up with the 2.5.1 util then i upgraded to plesk 5 and tried to restart with the 5.0.5 util. Here is my errors:

CODE
[root@www plesk]# cat dump_file | gzip -d | /usr/local/psa/bin/psarestore -m map_file -s shells_map_file -f -



gzip: stdin: not in gzip format



===============================================================================



Attempt to connect to MySQL server ... done



===============================================================================



Input file is not a valid MIME file: can not find MIME header.


Any info on this would be appreciated icon_neutral.gif
NightHawk
looks like you didn't use the g-zip tag when you did the dump...so you might want to remove it from your restore line:

| gzip -d
nacarls
ugh sorry for the fuss but i hit another problem.

Unable to add a system user ''username'':Error: empty argument HomeDir
Error occured during preparation for the object restoring.
Unable to retrieve necessary info on the destination directory location for the content restoring for object domain.

Im assuming this is due to the useradd commands and they are not set in the dump file correctly. Any way to fix this? It looks like the database has been installed successfully and just hangs after the users are failed. thanks for the help
NightHawk
QUOTE
Originally posted by nacarls
ugh sorry for the fuss but i hit another problem.  

Unable to add a system user ''username'':Error: empty argument HomeDir
Error occured during preparation for the object restoring.
Unable to retrieve necessary info on the destination directory location for the content restoring for object domain.

Im assuming this is due to the useradd commands and they are not set in the dump file correctly. Any way to fix this? It looks like the database has been installed successfully and just hangs after the users are failed. thanks for the help


hrm...that's one I havn't seen....

check the release notes for the backup utlities...it explains how to deal with "collosions" ...hopefully you can make something similar work for this...

(and post back with how you did it..when you figure it out cool.gif )
nacarls
NightHawk,

I do have a tarball of the entire psa directory. If i was to just extract this somewhere else theoretically couldnt I just mv the domain folder into the /usr/local/psa/home/vhosts/ folder minding that i stay away from default and webmail? The databases were setup correct...but the users were not. Quite frankly I have done something I didnt want to do...I became a statistic. Any help would deeply be appreciated at the point in time.
NightHawk
QUOTE
Originally posted by nacarls
NightHawk,  

I do have a tarball of the entire psa directory. If i was to just extract this somewhere else theoretically couldnt I just mv the domain folder into the /usr/local/psa/home/vhosts/ folder minding that i stay away from default and webmail? The databases were setup correct...but the users were not. Quite frankly I have done something I didnt want to do...I became a statistic. Any help would deeply be appreciated at the point in time.


might work...might not....if the psa db is intact...and all the config files are intact...that would work....if not..it won't.
nacarls
my problem is this...the back didnt work. Which really burst my bubbles. If i reinstall the 2.5.5 standard and use my tar file to restore. would my plesk key still be on it?
NightHawk
QUOTE
Originally posted by nacarls
my problem is this...the back didnt work. Which really burst my bubbles. If i reinstall the 2.5.5 standard and use my tar file to restore. would my plesk key still be on it?



probably not. It might have stayed...but it is not likely. You will probably need to re-install the plesk key.
nacarls
do you happen to know the download link for the plesk 2.5* versions? I know i can get the patches from teh mebers area of plesk but have been unable to find the full install. Any help on this again would be appreciated.

[edit]

The plesk support team has brought to my knowledge that my back will not be compatible with the plesk 5.0 install. So the idea of uninstalling plesk 2.5.5 completely then installing plesk 5.0 and trying to restore was not a good idea icon_neutral.gif. So, I am going to have to try to find my way back to the 2.5 version somewhow and hopefully upgrade to 5.0 without uninstalling plesk 2.5.5 What a nightmare.

[/edit]
NightHawk
QUOTE
Originally posted by nacarls
do you happen to know the download link for the plesk 2.5* versions? I know i can get the patches from teh mebers area of plesk but have been unable to find the full install. Any help on this again would be appreciated.

[edit]

The plesk support team has brought to my knowledge that my back will not be compatible with the plesk 5.0 install. So the idea of uninstalling plesk 2.5.5 completely then installing plesk 5.0 and trying to restore was not a good idea icon_neutral.gif. So, I am going to have to try to find my way back to the 2.5 version somewhow and hopefully upgrade to 5.0 without uninstalling plesk 2.5.5 What a nightmare.

[/edit]


Hrm...always works for me....as long as I am going standard to standard or rpm to rpm.... I have done backups on 2 separte 2.5.5 standard boxes and restored them to a single 5.0.4 (at the time) standard box...the restores went great. (as my customer with daily 12 + gig backups will atest to). (unless there is something wierd with your backup that I don't know about..or didn't catch when reading your posts)


As for the url's to the 2.5.* installs..I would suggest checking the plesk anonFTP..if they are no longer on the website in the downloads section.
nacarls
From what the support guys said, Plesk 2.5.x backup utils are not compatable with the psa 5.0.x backup utils. So, your data must be on the machine in order for it to transfer over. My problem here was thast I backed up from 2.5 then removed everything like you suggested. Then made a clean install of 5.0 standard(staid standard to standard) then tried to restore the data. But since the psa 5.0 utils are not compatable I had to remove 5.0 reinstall 2.5 then restore the data then upgrade to 5.0. With a clean install of 2.5 I was able to upgrade without any problems. Thanks for the help.
NightHawk
QUOTE
Originally posted by nacarls
From what the support guys said, Plesk 2.5.x backup utils are not compatable with the psa 5.0.x backup utils. So, your data must be on the machine in order for it to transfer over. My problem here was thast I backed up from 2.5 then removed everything like you suggested. Then made a clean install of 5.0 standard(staid standard to standard) then tried to restore the data. But since the psa 5.0 utils are not compatable I had to remove 5.0 reinstall 2.5 then restore the data then upgrade to 5.0. With a clean install of 2.5 I was able to upgrade without any problems. Thanks for the help.


the 5.0 backup utilities will restore the 2.5 backups.....I think that is where the difference comes in.....but you are correct the 2.5.5 backup utilities won't run on 5.0.*...

But anyway...glad it worked.
MattKD
Hi,

Thanks so much for this posting, I am trying out the script right now, it is in the process of backing up my server...does it backup E-Mail boxes as well as vhosts and the databases?

My Main question was do you know how to modify this script or add a new script that will upload the backup dumps that it creats to a specific FTP account etc?

Thanks for any help!

Regards, Matt
NightHawk
QUOTE
Originally posted by MattKD
Hi,

Thanks so much for this posting, I am trying out the script right now, it is in the process of backing up my server...does it backup E-Mail boxes as well as vhosts and the databases?

My Main question was do you know how to modify this script or add a new script that will upload the backup dumps that it creats to a specific FTP account etc?

Thanks for any help!

Regards, Matt


Yes, it backups everything plesk related....so basically to do a restore...you reinstall your OS... reinstall plesk...secure your box...then restore from the backup.

The easiest way to do the ftp part you are asking about...woudl be to use another script to grab the /dump1 directory and transfer it...
MattKD
Thanks so much for your help I really appreciate it..!

The backup since completed, split into 1gb files etc as it should, I will look around for the FTP part of the script to see what I can find.

Thanks again,

Matt
NightHawk
QUOTE
Originally posted by MattKD
Thanks so much for your help I really appreciate it..!

The backup since completed, split into 1gb files etc as it should, I will look around for the FTP part of the script to see what I can find.

Thanks again,

Matt



NP
MattKD
Hi Again,

Not sure if anyone is interested but here is some code that will perform the automatic FTP upload of your dump files...if required...

ftp -n ftp.backupserver.net <user username password
binary
prompt
mput *
quit



mput is set to * because the only files in my dump directory are the backup ones...if you need to change the port you can do so after the ftp address by leaving a space then putting the port number...Also if you are not already in your backup directory you can change to it with cd /dump1 before the mput.

Hope this is of interest to someone..!

Matt
NightHawk
of course..you could always just call the backup from the remote server...tunneling it over ssh...(much more secure then ftp anyway)...

something like this would work:

ssh -C -x root@domain.com /usr/local/psa/bin/psadump -F -f - --nostop --tar-ignore-failed-read | gzip | split -b 1000m - dump.


although you would have to allow direct root login for that to work....at least allow it from the backup server...
huck
The manual for the PSA backup utilities has a few examples:
http://download1.plesk.com/psa5.0/bu/build...1118.12/manual/

(you may need an account --free-- to read this not sure)

From the manual:
QUOTE
Chapter 4. Distributed backup and restore
Table of Contents

Backing up from the remote computer
Restoring from the remote computer
Simultaneous backup/restore
The distributed backup and restore are the option provided by the psadump and psarestore utilities. These utilities can be used in a fashion, which allows to back up a PSA server creating the dump-file on the disk of a remote computer as well as to restore a PSA server using the dump-file stored at the remote computer.

Backing up from the remote computer
The psadump utility can be used the following way to for backing up the remote PSA server information storing the dump-file at the local machine. This can be done, for instance, to provide the regular server backup.

ssh root@remotehost '/usr/local/psa/bin/psadump -f - --nostop' | split -b1000m - dump.  

NOTE
Please use caution when executing a backup with the --nostop parameter. See the details of using --nostop in order to avoid possible complications.

The backup of PSA can take up a considerable amount of disk space at the server. Using this technique you are both: saving the disk space at the server and placing the dump-file at a different location, which enhances the security of the backed up information.

Restoring from the remote computer
The psarestore utility much similar to the psadump utility allows executing remote restore operation. In this case the remote dump-file is used to restore PSA at the local server.

ssh root@remotehost 'cat /root/psa_backup/dump.*' | /usr/local/psa/bin/psarestore -f - -m my_ip_map_file -s my_shells_map_file  

This, like the above technique, is useful when you are unable or choose not to store the dump-file at the same machine with PSA.

Simultaneous backup/restore
Combining the two previously described techniques allow to execute the simultaneous backup/restore of a PSA server. This could be very useful when you need to work (make an upgrade or a similar operation) on your machine that is currently employed under PSA but you wish to decrease the idle time as much as possible. In such case you can simply enough migrate PSA from one machine to another.

ssh root@remotehost '/usr/local/psa/bin/psadump -f - --nostop' | /usr/local/psa/bin/psarestore -f - -m my_ip_map_file -s my_shells_map_file  
paulz
Possibly a stupid newbie question?

Considering I dont need to backup too frequently
would it be possible using ssh have root push Dump1 backup files to my home machine or is there any other method to do this?

Regards

Paul
NightHawk
QUOTE
Originally posted by paulz
Possibly a stupid newbie question?

Considering I dont need to backup too frequently  
would it be possible using ssh have root push  Dump1 backup files to my home machine or is there any other method to do this?

Regards

Paul


as long as your home box is linux ...so that it accepts ssh connections...sure...or if you have a ftp server, then just use ftp to transfer them.
MattKD
Hey...

Is there a way to extract individual sitesfiles etc from the plesk backups...?

Assume I have a site www.mysite.com and I want to restore the most recent version but leave everything else untouched is there a way to look inside my backup files and extract the relevant data?

Regards, Matt
NightHawk
QUOTE
Originally posted by MattKD
Hey...

Is there a way to extract individual sitesfiles etc from the plesk backups...?

Assume I have a site www.mysite.com and I want to restore the most recent version but leave everything else untouched is there a way to look inside my backup files and extract the relevant data?

Regards, Matt


add this line to your restore command: (or similiar)
--domains-names

then make a file called domains-names and put the domains you want to restore inside that. You may need to delete the existing domains first...so that you don't have collisions.
paulz
QUOTE
Originally posted by NightHawk
as long as your home box is linux ...so that it accepts ssh connections...sure...or if you have a ftp server, then just use ftp to transfer them.


Thanks NightHawk,

As Im currently using windows the best & quickest method ive found to download my dump files is using SCP (Secure CoPy) with PenguiNet just works the same as ftp but I believe more secure, this is really easy to use I highly recommend it.
Gentle Giant
On the restore you have a typo icon_smile.gif

The non gzip should be...

[PHP]
#####
###restore procedure
###for non-gzip backups
#####
cd /psadumps
cat dump.* | /usr/local/psa/bin/psarestore -m map_file -s shells_map_file -f -
vi map_file
vi shells_map_file
cat dump.* | /usr/local/psa/bin/psarestore -m map_file -s shells_map_file -f -
####################################
###end of include###################
####################################
[/PHP]

I think icon_wink.gif

BTW - you might also want to move this over to the new Plesk How-To forum icon_biggrin.gif
NightHawk
QUOTE
Originally posted by Gentle Giant
On the restore you have a typo icon_smile.gif

The non gzip should be...

[PHP]
#####
###restore procedure
###for non-gzip backups
#####
cd /psadumps
cat dump.* |  /usr/local/psa/bin/psarestore -m map_file -s shells_map_file -f -
vi map_file
vi shells_map_file
cat dump.* | /usr/local/psa/bin/psarestore -m map_file -s shells_map_file -f -
####################################
###end of include###################
####################################
[/PHP]

I think icon_wink.gif

BTW - you might also want to move this over to the new Plesk How-To forum icon_biggrin.gif


hrm...that's exactly what I have there.. icon_wink.gif ..(thanks for pointing it out..I must have typed too quick..I always do gzip backups).

As for moving this to the plesk how-to forum..I don't think I can actually do that...as I am not a mod for this how-to forum... (and to be honest..not sure about moving the how-to's around anyway..maybe should leave them where they are).
jyeung
Will this backup operation cause websites to be non-functional until the backup is complete? I read somewhere that this is the case.

I'm planning to order the backup service with Rackshack, so I need to know if it'll work out icon_smile.gif
Cranky
The --nostop parameter keeps apache, mail etc. live. e.g. no downtime
sallyanne
Are the Plesk backup utilities for Plesk 6 available yet? I tried to find them on the Plesk web site but couldn't see them.
NightHawk
QUOTE
Originally posted by sallyanne
Are the Plesk backup utilities for Plesk 6 available yet? I tried to find them on the Plesk web site but couldn't see them.


They are available via the plesk forums, but....they are BETA only...at this point...

I personally would not trust them on a production box, without testing them completely (and this is the recommendation that swsoft (formely plesk) makes in the post, as well.

Anyway, it looks like the backup/restore utilities will be released with plesk6.0.2 ...and since we are currently running 6.0.1, it shouldn't be too long...so my advice, would be to wait for the release version of the backup/restore utilities.

Anyway, just my .02cents.. cool.gif
md3v
Hi,

Are these scripts current and/or will they work with the PSA Backup Utilities just released for Plesk 6.01?

Thanks icon_smile.gif
autoquartz
Do I need to add this to my Crontab Manager in Plesk to have it automatically run every day? Thanks.
NightHawk
QUOTE
Originally posted by md3v
Hi,

Are these scripts current and/or will they work with the PSA Backup Utilities just released for Plesk 6.01?

Thanks icon_smile.gif


Yes, those work with the new plesk6 backup utlities....if you already had them setup and running on psa5.0.5..and upgraded to plesk6 and installed the new backup utlities they would continue to run with no problems. If you are just putting them on your new plesk6 box..as long as you have installed the backup utliites, then they will work as well.
NightHawk
QUOTE
Originally posted by autoquartz
Do I need to add this to my Crontab Manager in Plesk to have it automatically run every day?  Thanks.


If you follow the instructions in the first post of this thread...you will be setting them up in the cron manually and will not have to use the crontab manager in plesk to set them up. And actually, that would be the best way...as these do need to run as root.
juan
QUOTE
Originally posted by MattKD
Hi Again,

Not sure if anyone is interested but here is some code that will perform the automatic FTP upload of your dump files...if required...

ftp -n ftp.backupserver.net <user username password
binary
prompt
mput *
quit



mput is set to * because the only files in my dump directory are the backup ones...if you need to change the port you can do so after the ftp address by leaving a space then putting the port number...Also if you are not already in your backup directory you can change to it with cd /dump1 before the mput.

Hope this is of interest to someone..!

Matt


I have a problem to have the script running by itself, I've made a file with the code in it and I run it from the shell then the process abort:
QUOTE
Interactive mode off.
Permission denied.


Thanks
nacarls
you must give the script the execute priveledge ....

chmod 755 filename

this should take care fo teh problem. Also this script might require being run as root...although im not positive....depnds on the owner id imagine.
juan
QUOTE
Originally posted by nacarls
you must give the script the execute priveledge ....

chmod 755 filename

this should take care fo teh problem. Also this script might require being run as root...although im not positive....depnds on the owner id imagine.


Chown too root and chmod to 755 and it still give me the same result, I've tried to shown and run as another user and it also still the same... Thanks for helping!

icon_sad.gif
nacarls
as far as what this script does other then create a file on the destination server that has the same exact lines inthe script itself, it should still work.

first create a file "ftp_upload"

add the following to it adjusting where needed.

#!/bin/bash
ftp -n ftp.backupserver.com <user username password
binary
prompt
cd /path/you/want/
mput *
quit

then save it and close.
now chmod the file to 777
chmod 777 ftp_upload

now you shoudl be able to runthe file:

./ftp_upload

This will give you the interactive error still do to the nature of the ftp command....I believe. Its not a interective script icon_smile.gif, you just plug and chug info.

then if you ftp into your backup server yopu shoudl have a file int he desitination you selected with a new file called ftp_upload with the contents of this script in it.

hope that helps
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.