Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Daily Backups?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Daily Backups?

Hi I have multiple sites running on multiple VPS's. For the past few months I have been taking manual mysql and /var/www backups every few days.

I was interested in making this an automated process, but I am not sure how to go about it.

I have a Dedicated server with over 1TB of disc space for holding the backups.

How would I make each VPS automatically backup and send it's self to my Dedi?

Thanks

Comments

  • netomxnetomx Moderator, Veteran

    Place this on your /etc/crontab file:

    0 * * * *       root    rsync -az -e "ssh -p YOURPORT" username@IP:/var/www/* /path/to/backup
    0 * * * *       root    ssh user@IP "mysqldump -u backup_user -pbackup_password --all-databases | gzip -c" > /path/to/backup/sql/$(date +"%y-%m-%d_%H-%M").sql.gz
    

    And fill in your details

    Thanked by 1nadiar429
  • @netomx said:
    Place this on your /etc/crontab file:

    > 0 * * * *       root    rsync -az -e "ssh -p YOURPORT" username@IP:/var/www/* /path/to/backup
    > 0 * * * *       root    ssh user@IP "mysqldump -u backup_user -pbackup_password --all-databases | gzip -c" > /path/to/backup/sql/$(date +"%y-%m-%d_%H-%M").sql.gz
    > 

    And fill in your details

    Do I put that in the /etc/crontab file on the Dedi I want to use as backup? Or on the VPS?

    Thanked by 1nadiar429
  • netomxnetomx Moderator, Veteran

    Oh, I forgot:

    • That is in your backup dedi/VPS
    • Before restarting cron service, add the ssh key to your VPS. I'm not in my regular laptop so I can't give you the link, but investigate how to access ssh remotely without password.
  • VPNVPN Member
    edited December 2013

    I do similar to netomx except I use tar and scp instead of rsync as I like to get full complete backups. My understanding is that rsync just does the changed files.

  • edited December 2013

    Rsync avoid to do exact copies, it only copy the changes

  • VPNVPN Member
    edited December 2013

    I know but I like full backups for each day so I can roll back to a particular day if I need to.

    191213.tar.gz 181213.tar.gz 171213.tar.gz

    And so on.

  • HalfEatenPieHalfEatenPie Veteran
    edited December 2013

    This probably will get deleted (because... you know.. the "forum that shall not be named") but there's a script semi-finished here:
    https://vpsboard.com/topic/1439-stale-commands-in-htop/?p=23193

    The script I believe creates daily backup with the time and date of backup creation, and has it in tar compression, and also makes mysql database backups (if you need it).

  • @imtiax said:
    Do I put that in the /etc/crontab file on the Dedi I want to use as backup? Or on the VPS?

    I would create a script that does essentially that, tar up the files and mysqdump the db, then rsync to backup server and send you an email with log file.

    VestaCP has a pretty good backup system, you can take a look at their script and edit it to suit your needs.

  • VPNVPN Member
    edited December 2013

    Webmin has a good filesystem backup module built in that I use.
    Virtualmin also has it's own backup system for the virtual hosts and all their associated databases and Maildir's

    Both Webmin and Virtualmin can automatically transfer their backups to another location by means of FTP, SFTP or SSH.

  • netomxnetomx Moderator, Veteran

    Mine works fine, just adjust the rsync to scp, gzip to tar and that's all

  • qtriangleqtriangle Member
    edited December 2013

    @imtiax
    I wrote a script that I use to automate backups per client. You can even mention which account to exclude, and it manages daywise backups.
    This is for kloxo but you can use it with small changes to work for you.
    Send your email id in PM and I will share with you.

  • nunimnunim Member
    edited December 2013

    Make sure you restrict the backup user to the exact rsync command you want to run, otherwise if that key is compromised, they would be able to copy anything on the backup server that they have access to.

  • sleddogsleddog Member
    edited December 2013

    Use rsync as mentioned to maintain a current mirror on the backup server (including mysqldumps or mysqlhotcopies).

    Then, on the backup server, use something like rdiff-backup to build redundancy. For example you can have daily 'restore points' going back two weeks, or bi-weekly points for the last 12 weeks, etc. It's all in how you use rdiff-backup. Minimal diskspace usage, lots of redundancy.

  • @sleddog said:
    Use rsync as mentioned to maintain a current mirror on the backup server (including mysqldumps or mysqlhotcopies).

    Then, on the backup server, use something like rdiff-backup to build redundancy. For example you can have daily 'restore points' going back two weeks, or bi-weekly points for the last 12 weeks, etc. It's all in how you use rdiff-backup. Minimal diskspace usage, lots of redundancy.

    Great advice, similar to how we do in-house backups.

Sign In or Register to comment.