2

I have a little question for You. I manage a little dedicated server with Ubuntu Server 16.04 LTS installed.

I have searched a lot, but I don't found a solid and in first SIMPLE solution for backup my server to another server.

More details: I use Wordpress, Apache, Php, 2 Mysql Databases and SFTP services. Inside there are one domain and one subdomain active.

The question is: I just implemented a backup solution only for my websites contents. But in case the disk will be broken, for example, is there a way to backup all entire server (for example once a month) files and installed program (including the Operational System) and creat a kind of file that I can use to restore all the configurations/files/installed program in another server?

I have no fisic access to the server, and I don't have a Snapshot service avaible with the Hosting (Kimsufi).

I have found this suggest but I can't access to the GRUB: Tar solution.

Web Siena
  • 43
  • 1
  • 9

1 Answers1

3

There are plenty of tools you can use to copy filesystems around such as dd or rsync

rsync

Allows for copying over ssh

Copy your home directory to another server via ssh

rsync -a --delete --quiet -e ssh /folder/to/backup remoteuser@remotehost:/location/of/backup

Ful System backup

rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup/folder

And finally rsync as a disk cloning tool

rsync -qaHAXS SOURCE_DIR DESTINATION_DIR

from the man page

-H, --hard-links      preserve hard links
-A, --acls            preserve ACLs (implies -p)
-X, --xattrs          preserve extended attributes
-S, --sparse          handle sparse files efficiently

dd

I don't think you can use dd over ssh so you'll have to use a script to upload the file or just copy over to a usb stick but disk cloning (what I think you're asking about) is what dd was designed for

Clone an entire disk

dd if=/dev/sdX of=/dev/sdY bs=64K conv=noerror,sync status=progress

you might be able to try this workaround for using dd over an ssh tunnel though my advice would be to test it on a couple of vm's first before running it on bare metal as while dd is a powerful tool as uncle ben said 'With great power, comes great responsibility' it's easy to destroy filesystems with dd. Without further adieu... the workaround

ssh server1 'dd if=/some/file' | ssh server2 'dd of=/new/file/path'
j-money
  • 2,382
  • Thank you so mutch for your reaply. I have searched for dd but i readed that we must use a usb pendrive. I haven't a fisic access to the server. – Web Siena Aug 15 '18 at 18:36
  • after a little googling around it looks like there are workarounds to use dd over ssh I will update my answer to reflect this – j-money Aug 15 '18 at 18:39
  • Thank You j-money! So with rsync I can take another server, install the same operational system and make the Full System backup command, right? Just it? :-) – Web Siena Aug 15 '18 at 18:48
  • I'm not sure I undersantd your question :( I use both rsync and dd on my systems. I use rsync as a full system backup (not nessciarily a disk clone) as it saves alot of important files not caputred by my regular backup scripts. To use rsync as you want you may try rsync -qaHAXS SOURCE_DIR DESTINATION_DIR But i will update the answer to reflect this better – j-money Aug 15 '18 at 18:57
  • My intent is to avoid to reinstall e configure another server with same programms, files and settings if an unexpected event happens to the main server. Specially i don't like to reconfigure all settings of the website (php, apache, https, etc) – Web Siena Aug 16 '18 at 07:09