3

I have a CentOS6.9 Linux server remotely on a VPS Provider and I need to clone my remote server on my local computer as a Virtual Machine for examination purposes.


I made a full server backup without compression to another remote server (rsync.net) by using the following rsync command:

rsync -auHxv --numeric-ids --delete-after --progress --exclude="/etc/fstab" --exclude="/dev/*" --exclude="/proc/*" --exclude="/sys/*" --exclude="/tmp/*" --exclude="/boot/*" --exclude="/run/*" --exclude="/mnt/*" --exclude="/media/*" --exclude="/backup/*" --exclude="/lost+found" / -e ssh user@server.rsync.net:backup_directory


Would it be possible to use this backup as an image for cloning through Virtual Machine on my local computer, either by using VMWare Workstation or Virtual Box or any other Virtual Machine Platform ?

Cadmos
  • 133
  • 1
  • 5

1 Answers1

2

I would use DD over SSH and import that as a new VBox image after conversion. I use GZIP to skip copying gigs of empty space.

ssh root@remoteIP  "dd if=/dev/sda | gzip - " | dd of=image.gz

Uncompress and convert.

gunzip image.gz 
VBoxManage convertdd image image.vdi --format VDI
Joe M
  • 301
  • 1
  • 4
  • Thanks. How exclusions are declared ? – Cadmos Jun 04 '18 at 18:01
  • Hey @Cadmos unfortunately DD does not have such a concept. If you wanted to use rsync *I* would just install the same OS in VBox then run your rsync from there. I think that would be quickest. Although DD would give you a 1:1 copy of the disc. – Joe M Jun 04 '18 at 19:30
  • I agree it would be better using DD however the free disk space on the VPS that is to be backed up has not enough disk space (almost 20%) and I have to exclude at least /home dir which has the cpanel accounts in. – Cadmos Jun 04 '18 at 19:45
  • my disk is 100GB however now only the 23GB are being used. DD /gzip will create an image of the total capacity of the disk or only for the used space, meaning the 23GB, so the image will be equal/lesser than 23GB ? – Cadmos Jun 05 '18 at 11:01
  • Hey @Cadmos - Using GZIP it should be ~23GB or less, it compresses all the empty space to 0 bytes. Hopefully you should gain some more compression from GZIP as well. When you GUNZIP it, it will be 100GB though. – Joe M Jun 05 '18 at 21:43
  • You've right. However I followed all of your steps and after loading the image.VDI in Virtual Box it ends with Fatal: `No bootable medium found!` (Sorry for not voting up your answers, I have not enough score for letting me vote up answers/comments) – Cadmos Jun 07 '18 at 17:19
  • @Cadmos Did you found a solution ? I also want to create a VM from my VPS, but not able to boot on it with this solution. I think my VPS provider have custom /boot images – ReaperSoon Jun 18 '21 at 09:51