5

I have a question about a FreeBSD server that I cannot access at the moment. But because we would like to try some new stuff we want to create a backup of this system first.

The question is: is there any possibility to create a disk image over ssh from the whole server disk that is currently a live system?

If there is: I would like to know how to do this.

3
  • Possibly relevant: superuser.com/questions/410940/… – Der Hochstapler Jan 8 '13 at 22:42
  • Thanks for your quick response, but this method keeps involving access to the system for the live-cd. I need to do it remotely from my home, while the server is at the company. – rfverbruggen Jan 8 '13 at 22:50
  • Yeah, I understand that. The outcome of the question I mentioned might be an indicator that what you're trying to achieve is not possible. – Der Hochstapler Jan 8 '13 at 23:04
3

It's not really possible under Linux. The reason it is under Windows is Volume Shadow Copy.

If your system uses LVM you can take a snapshot and then rsync that over for an atomic copy of the files, you would need to restore partitions/boot loader however.

Easiest method if it must be done, is use dd to copy it:

dd if=/dev/sda | ssh user@remotehost 'dd of=/path/to/output'

And then in order to make 100% sure your files are ok, rsync from the running one on to the drive you dd'd the image to once you've mounted it. (I've skipped rsyncing the differences hundreds of times with no ill effects, but that is only on heavily read based server access)

1
  • There are many, many ways to do this ... you just listed one. you could even throw a compression algorithm in that pipe. – fuzzyTew Mar 27 at 19:53
4

Use dump(8) to create a snapshot of the (file)system.

dump -0aLf /path/to/dumpfile /

That will create a live dump of the root-filesystem and save it to /path/to/dumpfile. That dump can be transferred over ssh to another computer. Or you can do it in one go by the use of this.

dump -0aLf - | ssh my.backup.server dd of=/path/on/my/server/dumpfile

That can later be restored by the following:

cd /where/I/should/restore
restore -xf /path/to/dumpfile

Applications such as databases will have to be handled separately. With a MySQL database for instance you have mysqldump to create a textfile of sql commands that can be run on another MySQL server in order to be imported there. Other databases have similar methods.

1
  • Second dump command doesn't include destination. – artscan Mar 29 '17 at 5:15
1

if there is only a root-fs to copy simply on your target machine use something like:

rsync --numeric-ids --delete -vax source_machine:/ /target_dir

twice or more often. The second run already reuses cached entries from the first run, goes very fast and gives almost a real snapshot with some restrictions. You can watch the 'atomicness' by simply repeating the 'rsync' an arbitrary amount of times. There mostly are very few files (logfiles and such) that really changed between the iterations (and thus need to be copied/deleted).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.