Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Possibly relevant:… – Oliver Salzburg 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. – Oliver Salzburg Jan 8 '13 at 23:04
up vote 3 down vote accepted

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)

share|improve this answer

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.

share|improve this answer

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).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .