Backups

Discussion in 'Linux VPS/Dedicated - cPanel' started by Storm3y, May 6, 2013.

  1. Storm3y

    Storm3y New Member

    Hi,

    I'm looking to backup each cPanel accounts home directory and MySQL databases every day to a remote FTP server (GoDaddy). I know cPanel has a built in feature to do this but it currently doesn't delete backups after a period of time.

    I would like to keep 7 days worth of backups for each account. Any idea what the best solution would be?


    Thanks
     
  2. KH-Jonathan

    KH-Jonathan Director of Managed Services Staff Member

    Does the other account give you access to a crontab (assuming it's Linux)?

    If so, you could write a quick cron to delete files older than 7 days, then use cPanel's built in backup feature.
     
  3. Storm3y

    Storm3y New Member

    I have a cPanel account on the server with crontabs ability for cron tabs. I have also noticed that the cPanel backups aren't time / date stamped so they get overwritten every night.
     
  4. KH-Jonathan

    KH-Jonathan Director of Managed Services Staff Member

    You could add a cron with code similar to this.

    Code:
    find /backup/ -mtime +7 -exec rm '{}' \;
    This will delete files older than 7 days in the given folder "/backup".
     
    Mike54 likes this.
  5. Storm3y

    Storm3y New Member

    How would I do this over FTP?
     
  6. KH-Jonathan

    KH-Jonathan Director of Managed Services Staff Member

    This would go in the crontab of the remote server. FTP backups would be enabled normally.

    You'd need to change /backup to the proper location of the backup storage.
     
  7. Storm3y

    Storm3y New Member

    Ah the remote server is just a FTP server from GoDaddy. Would it be possible to run that crontab on my VPS with you guys?
     
  8. KH-Jonathan

    KH-Jonathan Director of Managed Services Staff Member

    In theory, sure, but there won't be much of a clean way to keep the password secure as it would be plainly visible in the crontab.
     
  9. Dan

    Dan Moderator

    Hi Storm3y,

    You'd need something with a bit more flexibility than a standard FTP server in order to be able to do this unless the FTP server also support SSH. You could give the backup files the same names on a rotating schedule if whatever you're using to do backups supported it, WHM backups wouldn't as you can't enter custom names there.

    Have you considered using Amazon's S3? I wrote a script that is in the tutorial section here for it that wouldn't be too difficult to modify.
     
  10. Storm3y

    Storm3y New Member

    Hi Dan,

    Amazon S3 would be good however it is just too expensive for what we want. We have GoDaddy online storage which costs $24.99 per year however it only has FTP and not SFTP.

    We had a cronjob setup on our old VPS however I have lost it.
     
  11. Storm3y

    Storm3y New Member

    Hiya,

    any ideas on how to do this?


    Cheers
     
  12. KH-Jonathan

    KH-Jonathan Director of Managed Services Staff Member

    You need a cronjob to copy the file, and then delete the file also via FTP based on date. This could be put in a cron run from your VPS.

    I'll see if I can't come up with a cronjob to do this for you in the morning.
     
  13. Storm3y

    Storm3y New Member

    Hey Chap,

    Did you manage to come up with anything?


    Cheers
     

Share This Page