Howdy, Stranger!

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


Best practise taking and restoring VPS 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.

Best practise taking and restoring VPS backups

myhkenmyhken Member
edited February 2014 in Help

I have yet a question to ask here on LET.

I'm just testing out some rsync option between servers, and just found out about the complete server command rsync -aAXv /* 10.129.xxx.xxx:/ --exclude={/dev/*,/proc/*, /sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}

After some testing I found out that using this command to backup the complete server from iwStack to DigitalOcean did not work.
But there is no issues at all using it from one DO server to another.

How can I take a complete backup of my VPS server, that I can restore on any other server without any issues? (I may have to change the ifcfg-eth0 settings).

Today I only use Virtualmin backups, but I have to setup a new server with all settings before I can load my Virtualmin backup of my domains. This time I want to try a complete backup of all the content.

Any advice?

Comments

  • You might need to do something with the hardlinks.

    I use -avHK for single folder webapp transfers. Tack on whatever else you need.

  • pbalazs123pbalazs123 Member
    edited February 2014

    I'm always using this script, after completion just rsync that tar to somewhere. Pretty cool:

    pastebin.com/RG3vUkiE

    Restore is an other questions. But at least i have a daily backup from most important config files.

    Thanked by 1myhken
  • myhkenmyhken Member
    edited February 2014

    Got some error with the filesystem after reboot.

    Just tested a new setup now. Have taken a complete rsync backup from one of my iwStack servers to one test server at DO.
    Then I created a new VPS server at iwStack, and then used rsync to transfer all my files from the DO server. Then I rebooted my new iwStack server, and everything worked 100%. All files, all settings, everything worked.

    So this can work, just have to find out why it do not work between DO and iwStack.

    @pbalazs123, will check this out.

  • Hmmm, did not work very good, got this after some few minutes of running the new server:

    why?

  • pbalazs123pbalazs123 Member
    edited February 2014

    Hmm, did not ever tried restore it. I mean completely. I have always used just for config file backup as i mentioned above.

  • @myhken said:
    Hmmm, did not work very good, got this after some few minutes of running the new server:

    Did you transfer hardlinks?

  • @sycotic said:

    Should I use -avHK when I take my backup or when I restore the backup, or both?

  • I can not reboot my new server anymore, just goes in Kernel panic mode.
    Good it was only a test, rebuilding it now.

  • sycoticsycotic Member
    edited February 2014

    Depends on your backup procedure. You can just straight up rsync one server to another over ssh without "taking or restoring".

    I am assuming you are following something like: https://wiki.archlinux.org/index.php/Full_System_Backup_with_rsync

    Ninja Edit: Also, you are using the exact same images on both ends right? Nothing like 32 bit -> 64bit or Debian 7 ->Debian 6 stuff?

  • @sycotic yea, was just the guide I'm using. Can try a direct rsyncing, but the point with this project, is to store a complete backup on a backup server of all my servers, updated as often as I like, and if I have to rebuild the server I just can use the backup, and then the new server is up and running without me having to make allot of work.

    Maybe it's not possible, at least, not between different hosts. (but both DO and iwStack are using KVM servers)

  • sycotic said: Ninja Edit: Also, you are using the exact same images on both ends right? Nothing like 32 bit -> 64bit or Debian 7 ->Debian 6 stuff?

    Yes, CentOs 6.5 32bit on both sides. Also used yum update -y on both servers to make sure it was update to the latest.

  • craigbcraigb Member
    edited February 2014

    @myhken seems you can't run your own kernel on DO so whilst you are rsyncing your kernel, it's modules, initrd etc, those aren't getting used. Try matching the kernel versions - use the same version on iwstack as offered by DO and try again? It's another question whether you want to live with that (DO) limitation though...

    EDIT: see this DO support thread for more https://www.digitalocean.com/community/questions/do-you-update-kernels-sometimes

  • @craigb I have to say that I still get the Kernel panic, rsyncing from one iwStack server to another iwStack server using the command provided over, now with -avHK that @sycotic mention.

    But now it's time for a little computer break...then I will try the two guides @sycotic linked to.

    A quick question before I take a brake. If rsyncing the whole / is not a good idea, what folders can I copy without messing with the kernel, but still taking backup of all things, including Virtualmin and its settings.

  • sycoticsycotic Member
    edited February 2014

    @myhken said:
    craigb I have to say that I still get the Kernel panic, rsyncing from one iwStack server to another iwStack server using the command provided over, now with -avHK that sycotic mention.

    Sorry. I keep my webapps in a single folder and then use that to transfer them. Still have to do some setup to make sure that they will run after that.

    A quick question before I take a brake. If rsyncing the whole / is not a good idea, what folders can I copy without messing with the kernel, but still taking backup of all things, including Virtualmin and its settings.

    Depends on where you keep virtualmin and its settings.

    Edit: For example. If you keep virtualmin settings in /webapps/virtualmin you can backup /webapps/ and then when you restore your server install virtualmin from repo then point it at your config files. You can write a restore script to do this if you have to do it alot. This would make it so your backups are not dependent on specific kernels or binaries. You could also keep the rpm/source for the binaries for whatever webapp you have there too for easy install and/or to keep the same binary version. This will help separate your dependance on a specific set of kernels/hardware. (For example I can transfer my nxinx reverse proxies between centos and debian with minimal work).

    Thanked by 1myhken
  • Hoping on backup all Virtualmin settings also, but if it's not possible then it's not possible

  • You could also try throwing all your stuff into a docker container.

    Thanked by 1sycotic
  • sycoticsycotic Member
    edited February 2014

    tchen said: docker container

    I love the internet.

  • GoodHostingGoodHosting Member
    edited February 2014

    Why not use Tarnsap?

    tarsnap -cf "$(hostname)-`\%Y-%m-%d`" /
    

    Easy.

  • @HardCloud said:
    Why not use Tarnsap?

    Will that solve the kernel panic when I restore the backup on any other VPS server?

  • @myhken said:

    Tarsnap automatically ignores/excludes artifical filesystems (like procfs and a few others), I have safely and successfully restored FULL backups (when the partitioning was identical**) from one VPS, noto another VPS of the same OS and distro version using tarsnap.

    It is worth noting that you need to scrub UUIDs and a few other things to make your backup "portable", such as making sure that your /etc/fstab and /boot/grub/grub.conf & menu.lst are pointing at partition paths, and not at UUID=##### partitions.

  • @HardCloud: But I understand correct that I have to pay for their services?

  • FrankZFrankZ Veteran
    edited February 2014

    @myhken - I have gone down this path myself. I found that the fastest most consistent way was to run openVZ containers inside the KVM. I have an install routine that sets up the KVM quickly and then can backup/restore/migrate between KVM "nodes" without any issues. To migrate the KVM is do'able but prone to problems when you least want them. I can post details if you wish to go this way.

    EDIT: Does not work with DO

  • @FrankZ thank you for the offer. But I'm thinking this is going to be to advanced for me. just wanted to know if there was a very easy rsync (or similar) command that I could use to take backups, maintaing them, and then restore within minutes if I wanted, on any host.

    I have made a "autoconfig" script that I run on any new server now, it configures my new server with Virtualmin, firewall, SSH port etc etc. I have also found out how I can make some of my normal settings in Virtualmin.
    Then i only have to upload my Virtualmin backups, and then all is online.

    So maybe I should not ask for anymore. Can't be to simple ;)

  • You may also want to look at rsnapshot. (credit to Spirit)

    Thanked by 2myhken zimbo
  • @sycotic said:
    I love the internet.

    I love it too. <3 hugs

  • howardsl2howardsl2 Member
    edited February 2014

    Here is an article on server migration (using rsync) that I found very useful. I successfully used it to migrate my server from another provider to DigitalOcean:
    http://www.rackspace.com/knowledge_center/article/migrating-a-linux-server-from-the-command-line

    And here is the rsync "exclusion list" I used during that migration. Hope this helps!
    https://gist.github.com/hwdsl2/ae8e55cb2f70a5df4a72

    By the way, after the migration I would carefully inspect the excluded folders for any necessary files and manually "rsync" those.

    Thanked by 1myhken
Sign In or Register to comment.