-1

Is it possible to clone HDD with dd command on linux while server is up and running. Server running, Apache, MySql, NGINX. I ask this coz won't have downtime.

2 Answers2

2

No, at least not in a way that the clone is usable and consistent and while the source disk/partition is in use. The reason is that the disk content will be altered during the dd run and dd won't notice it. You will end up with a broken and inconsistent file system.

There are many better ways to backup a running server.

Sven
  • 97,248
  • 13
  • 177
  • 225
  • "There are many better ways to backup a running server."..can you please suggest one? – Mala Sirena Sep 04 '14 at 12:15
  • rsync, Bacula, Amanda, countless other backup tools. Depends on your situation, but we don't do product recommendations. – Sven Sep 04 '14 at 12:17
  • We could recommend a *process* (which you could use to shop for products if any were needed), but only if we had much more information about your environment and data. – David Spillett Sep 04 '14 at 15:16
1

Not with zero down time, though maybe with near-zero downtime depending on your setup and what you are trying to make a clone for (please add more detail to your question to describe exactly what you are trying to achieve).

If you copy direct from an active partition you will get an inconsistent corrupt response because as you are part way through there could be changes made both before and after your current reading point: you'll get the newer information after that point but not before. In fact services might be holding updates in memory that dd never sees as they have not yet written them to disc.

If your system is using LVM to manage block devices for filesystems and you have enough free space in your volume groups to create snapshots then you could do the following:

  1. Stop all the services.
  2. Create LVM snapshots for each relevant filesystem.
  3. Restart the services (so you have some downtime, but only that needed to stop the services, create the snapshots (which is near instant) and restart the services).
  4. Backup the snapshots instead of the original volumes using dd or other.
  5. Remove the snapshots when you are done.

Of course this way you don't get any updates that are made during the process, and it'll only work at all if you are already configured to use LVM (converting to that would require considerable downtime).

David Spillett
  • 22,534
  • 42
  • 66