1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

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

Discussion in 'Plesk for Linux - 8.x and Older' started by willgnosis, May 5, 2010.

  1. willgnosis

    willgnosis Guest

    0
     
    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
     
  2. clinton4

    clinton4 Regular Pleskian

    27
     
    Joined:
    Oct 23, 2008
    Messages:
    101
    Likes Received:
    0
    Hi willgnosis,

    When saving all databases in one dump file, how is the process of restoring only one database from that dump file?
     
  3. DharmeshK

    DharmeshK Guest

    0
     
    Thank you will for sharing this. it helped me a lot and saved my time.
     
  4. lvalics

    lvalics Silver Pleskian Plesk Guru

    36
    43%
    Joined:
    Jun 20, 2003
    Messages:
    965
    Likes Received:
    32
    Location:
    Romania
  5. Lee RB

    Lee RB New Pleskian

    10
    35%
    Joined:
    Dec 31, 2012
    Messages:
    8
    Likes Received:
    0
    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!!
     
  6. Lee RB

    Lee RB New Pleskian

    10
    35%
    Joined:
    Dec 31, 2012
    Messages:
    8
    Likes Received:
    0
    Really, no help what so ever!!

    I would really appreciate some to fix the log error not being emailed to me!!
     
  7. freesoul

    freesoul New Pleskian

    6
     
    Joined:
    Jan 15, 2014
    Messages:
    1
    Likes Received:
    0
    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: Jan 22, 2014
Loading...