Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instructions for using ntfsclone #3292

Merged
merged 3 commits into from
Nov 23, 2017

Conversation

milkey-mouse
Copy link
Contributor

@milkey-mouse milkey-mouse commented Nov 6, 2017

Fixes #81 and fixes #3259.

docs/faq.rst Outdated
--------------------------------------------------

Full disk images are as large as the full disk when uncompressed and don't get much
smaller post-deduplication after heavy use. This is because virtually all file systems
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess one can't tell the dedup reduction that general (the user might have tons of duplicate data in existing files).
but it gets clearer what you mean in the following text, so maybe fix phrasing above like "and might not get...".

docs/faq.rst Outdated

ntfsclone can only operate on filesystems with the journal cleared (i.e. turned-off
machines) which somewhat limits its utility in the case of VM snapshots. However,
when it can be used, its special image format is even more efficient than just zeroing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it still more efficient over time, like when you daily use the VM and backup it with borg?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would need to write a test script (edit some files in NTFS partitons & create archives with zeroing vs. ntfsclone format, rinse & repeat, compare final sizes) but the ntfsclone man page recommends always using the special format if you can control both backup and restore (as we do here). ntfsclone can clone to sparse files, so maybe once #14 is implemented that could simplify these instructions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess the stuff we need to compare for efficiency are these:

  • zeroing free space + running borg on the block device with --read-special (reading all the zeros will take a while, but they will dedup / compress to almost nothing. also, everything else stays in place and unchanged sectors will likely dedup ok with future block device images)
  • using ntfsclone in special format (maybe dedups badly with future dumps due to special format?)

docs/faq.rst Outdated
borg create repo::hostname-partinfo-mbr-gap sfdisk.txt mbr_gap
sfdisk -l -o Device,Type /dev/sdX | grep NTFS | cut -d' ' -f1 | while read x; do
ntfsclone -s -o - $x | borg create repo::hostname-part$(echo $x | grep -Eo "[0-9]+$") -
done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this reads a bit strange as this seems to be about a physical disk / machine and last thing you mentioned above was a VM.

maybe add a "check this!" in the comment of the dd, it depends on layout. there is no problem if we save a bit more than needed, but there might be a problem if we do not save the whole gap (if it is larger).

you practically tested the script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it on a MBR-formatted loopback device with a few NTFS partitions, I am testing it with a full windows installation right now.

On second thought I think saving the MBR with sfdisk is kind of redundant, when copying all space leading up to the first partition should do virtually the same thing. I can parse that out of the sfdisk output (it seems to always be 2048 bytes on MBR disks). Maybe instead I should use dd to copy up to the first partition and then use partprobe to notify the kernel of the new partition layout instead of using sfdisk at all.

Should these instructions back up every partition, NTFS or not, using ntfsclone for ntfs ones? At that point this is becoming more full bash script territory instead of just a snippet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested it on a Windows VM, which obviously used the MBR format. I added several partitions and checked restore, all the files were in the same places on the secondary NTFS & fat32 partitions and Windows booted (obviously I didn't meticulously check every windows system file but if it booted I'm assuming they stayed in place).

docs/faq.rst Outdated

borg extract repo::hostname-partinfo-mbr-gap
sfdisk /dev/sdX < sfdisk.txt
dd if=mbr_gap of=/dev/sdX bs=1M
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the dd is writing over the mbr, which was just edited by sfdisk.
also maybe rather use count=2048, like above.

docs/faq.rst Outdated
dd if=mbr_gap of=/dev/sdX bs=1M
sfdisk -l -o Device,Type /dev/sdX | grep NTFS | cut -d' ' -f1 | while read x; do
borg extract --stdout repo::hostname-part$(echo $x | grep -Eo "[0-9]+$") | ntfsclone -r -O $x -
ntfsclone -s -o - $x | borg create repo::hostname-part -
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this line for?

Copy link
Contributor Author

@milkey-mouse milkey-mouse Nov 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be there, I copy-pasted the wrong line from my test script :P

@milkey-mouse milkey-mouse force-pushed the document-ntfsclone branch 2 times, most recently from 59fb29b to fbc5be4 Compare November 7, 2017 22:52
@milkey-mouse
Copy link
Contributor Author

shall I collapse the ntfsclone fixup?

@ThomasWaldmann
Copy link
Member

yes.

maybe we should even move the whole stuff into docs/misc/disk-imaging.txt or so? gets rather long for a faq entry and includes quite some scripting...

@milkey-mouse
Copy link
Contributor Author

I agree, especially if we add a section with benchmarks for ntfsclone special/ntfsclone zeroed/zerofree/raw --read-special, we will need a separate docs page.

@milkey-mouse
Copy link
Contributor Author

When you say to move everything into a disk-imaging.txt, do you mean something like putting both FAQ entries in the txt and reference it from its former place on the FAQ page?

@ThomasWaldmann
Copy link
Member

yes. alternatively, it could be an own chapter about disk imaging. not sure what's better, a docs section is maybe easier discoverable, so it would not need a link from faq.

@milkey-mouse
Copy link
Contributor Author

milkey-mouse commented Nov 22, 2017

The new page could go under the Deployment section, then we can keep its formatting as well

@ThomasWaldmann ThomasWaldmann merged commit 483d3e8 into borgbackup:master Nov 23, 2017
@milkey-mouse
Copy link
Contributor Author

milkey-mouse commented Nov 23, 2017

If existing content is being moved to a new place, we don't want links to 1.1 docs to break. Should this still be backported?

@ThomasWaldmann
Copy link
Member

if someone wants permanent links, a link to a specific version can be used (like 1.1.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update docs bounty (11) try / document borg + ntfsclone
2 participants