FAQ SearchLogin
Tuxera Home
View unanswered posts | View active topics It is currently Fri Jun 18, 2021 19:50



Post new topic Reply to topic  [ 17 posts ] 
Backup ntfs partition 
Author Message

Joined: Mon Dec 06, 2010 18:34
Posts: 9
Post Backup ntfs partition
I have a lot of kvm virtual machines under Windows 2008 Server. So I want to do backup under host sytem. I can create a lvm snapshot and using kpartx mount ntfs partition. But I realize that I can't copy files from mount to backup directory whith saving all attributes.
Then I use ntfs-3g.secaudit to get nfts ACL list (for apply they someday).
But then I have problem with directories as "Documents and Setting". They are symlinks, are'n they. Can anybody explain me how can I create one-to-one copy of my mount to another folder saving all ntfs attributes?


Mon Dec 06, 2010 18:44
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: Backup ntfs partition
Hi,

Quote:
Can anybody explain me how can I create one-to-one copy of my mount to another folder saving all ntfs attributes?


The file http://b.andre.pagesperso-orange.fr/tools.zip contains a few tools, among them "ntfscp.c" shows how you can copy a full directory tree, along with attributes :
- the DOS attribute,
- the short name (8+3) if any,
- the time stamps (including creation time),
- the reparse data (for junctions and symlinks),
- the object_id (for windows shortcuts),
- all user extended attributes,
- the ACL (the NTFS one).
The compression state is preserved (unless you disable compression altogether), and the encrypted files are copied without decryption (provided you mount both source and destination with option efs_raw). However sparse files are copied without skipping the holes.

Of course, both the source volume and the destination volume must be formatted as NTFS.

This is just a demonstration program, you may have to fix a few things.

Regards

Jean-Pierre


Mon Dec 06, 2010 22:42
Profile

Joined: Mon Dec 06, 2010 18:34
Posts: 9
Post Re: Backup ntfs partition
Tnx this utility. It's greate.
Can u advice me how can I do a diff ntfs backup? After some time when I used ntfscp.


Tue Dec 07, 2010 14:53
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: Backup ntfs partition
Hi,
Quote:
Can u advice me how can I do a diff ntfs backup?

I have just inserted into the tools.zip file a shell script "ntfscp.sh" which does roughly the same as "ntfscp.c". It is easier to adapt to specific needs, in particular you can replace the "cp -p $1 $2" by a "cp -up $1 $2" or a "rsync". You can also organize this as an option (but beware, it is a recursive command, moreover I stumbled on bugs in getfattr).

Note : just written, more testing needed, feedback welcome.

Regards

Jean-Pierre


Tue Dec 07, 2010 15:56
Profile

Joined: Mon Dec 06, 2010 18:34
Posts: 9
Post Re: Backup ntfs partition
It's awesome! Big thnx.
But I have problems with files and directories where path contain spaces or special symbols. Such as "Documents and Setting" folder.


Tue Dec 07, 2010 18:51
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: Backup ntfs partition
Hi,

Quote:
But I have problems with files and directories where path contain spaces or special symbols.

Even Microsoft has recognized that this is unneeded pain, by renaming the Windows standard directories,... and symlinking the legacy names so that the problem does not go away....

You have to double-quote $1 and $2 (to "$1" and "$2") nearly everywhere,...

Regards

Jean-Pierre


Tue Dec 07, 2010 19:13
Profile

Joined: Mon Dec 06, 2010 18:34
Posts: 9
Post Re: Backup ntfs partition
Only double-quote don't help. Because "for" loop doesn't understand spaces to. I replays:
Code:
for f in `/bin/ls "$1"`
to
Code:
ls "$1" | while read f 

And change check in head
Code:
if [ -d $1 ]

to
Code:
if [ -d "$1" ] && ! [ -h "$1" ]

There is might be a hang.
I test it now. So to be continuous...


Tue Dec 07, 2010 19:36
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: Backup ntfs partition
Hi,

Thanks for the proposed fixes.

FYI the bugs in getfattr(1) I mentioned have been confirmed by Fedora, with fixes suggested. The reports are in https://bugzilla.redhat.com/show_bug.cgi?id=660613 and https://bugzilla.redhat.com/show_bug.cgi?id=660619

To work around them I had to complexify the tests related to junctions, so keep them until you get getfattr fixed.

Regards

Jean-Pierre


Tue Dec 07, 2010 22:06
Profile

Joined: Mon Dec 06, 2010 18:34
Posts: 9
Post Re: Backup ntfs partition
Thx for issues.
Using your script, I wrote script for copy ntfs-to-ntfs.
It use rsync to copy files, next it get all NTFS Extended Attributes and write them to a output file (bash script file). This output file I transfer to remote server and run it there. The output file apply all Extended Attributes to this copy.
Here is script http://dl.dropbox.com/u/1010374/ntfscp2.sh
Can u look at it when you'll have a free time. Maybe there is some errors or you can help me to upgrade it. Tnx


Thu Dec 09, 2010 22:25
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: Backup ntfs partition
Hi,

Quote:
I wrote script for copy ntfs-to-ntfs.

And you are a shell expert...
Quote:
Maybe there is some errors or you can help me to upgrade it.

There is an easy one : a space is missing in [ -z $2 ] at line 183
The one with $Recycle.Bin is harder. You have to somehow escape the '$' for $Recycle not to be taken as a variable. Maybe with some character substitution like `echo $2 | sed -e 's/\$/\\$/g'`

Regards

Jean-Pierre


Fri Dec 10, 2010 16:50
Profile

Joined: Mon Dec 06, 2010 18:34
Posts: 9
Post Re: Backup ntfs partition
Issues have fixed. All work fine. At least I hope so. =)
Try, test, have fun =)
Link: http://dl.dropbox.com/u/1010374/ntfscp2.sh


Fri Dec 10, 2010 20:30
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: Backup ntfs partition
Hi,

Quote:
Issues have fixed. All work fine. At least I hope so

Nice achievement. Congratulations.

Actually one thing is missing : Vista junctions and symlinks have a short name, an attrib, an ACL, etc. But the bug in getfattr(1) is difficult to work around. To check whether you have a buggy version, just try (on Vista or subsequent) :
Code:
getfattr -h -n system.ntfs_dos_name "/vista/Documents and Settings"

and see whether the link is followed.

Regards

Jean-Pierre


Sat Dec 11, 2010 11:29
Profile

Joined: Mon Dec 06, 2010 18:34
Posts: 9
Post Re: Backup ntfs partition
Code:
[root@host mnt]# getfattr -h -n system.ntfs_acl "./test2/Documents and Settings"
# file: test2/Documents\040and\040Settings
system.ntfs_acl=0sAQAElHAAAAB8AAAAAAAAABQAAAACAFwABAAAAAEAFAA
BAAAAAQEAAAAAAAEAAAAAAAAUAKkAEgABAQAAAAAAAQAAAAAAABQA/w
EfAAEBAAAAAAAFEgAAAAAAGAD/AR8AAQIAAAAAAAUgAAAAIAIAAAEBAAAA
AAAFEgAAAAEBAAAAAAAFEgAAAA==

[root@host mnt]# getfattr -h -n system.ntfs_dos_name "./test2/Documents and Settings"
# file: test2/Documents\040and\040Settings
system.ntfs_dos_name="DOCUME~1"

There are all right, aren't they?


Tue Dec 14, 2010 17:31
Profile

Joined: Mon Dec 06, 2010 18:34
Posts: 9
Post Re: Backup ntfs partition
And out from the target of symlink:
Code:
[root@host mnt]# getfattr -h -n system.ntfs_acl "./test2/Users/"
# file: mnt/test2/Users/
system.ntfs_acl=0sAQAElKAAAACwAAAAAAAAABQAAAACAIwABgAAAAADFAD/AR8AAQ
EAAAAAAAUSAAAAAAMYAP8BHwABAgAAAAAABSAAAAAgAgAAAAAYAKkAEgABAgAAAA
AABSAAAAAhAgAAAAsYAAAAAKABAgAAAAAABSAAAAAhAgAAAAAUAKkAEgABAQAAAAA
AAQAAAAAACxQAAAAAoAEBAAAAAAABAAAAAAECAAAAAAAFIAAAACACAAABBQAAAAAA
BRUAAABZUbgXZnJdJWRjOwsBAgAA


Tue Dec 14, 2010 17:39
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: Backup ntfs partition
Hi,

Quote:
There are all right, aren't they?

Yes, you are lucky.
This is what I get with attr 2.4.44-5 :
Code:
[linux@pavilion2 c-src]$ getfattr -h -n system.ntfs_dos_name "/vista/Documents and Settings"
getfattr: Removing leading '/' from absolute path names
# file: vista/Documents and Settings
system.ntfs_dos_name="DOCUME~1"

# file: vista/Documents and Settings/All Users
system.ntfs_dos_name="ALLUSE~1"

# file: vista/Documents and Settings/Default
system.ntfs_dos_name="DEFAULT"

etc.

This is why for copying the symlink, I had to restrict to the first couple of lines and check whether the first one ends with the exact expected name.
The patch suggested by Fedora fixes it (see the link in a previous post).

Regards

Jean-Pierre


Tue Dec 14, 2010 19:42
Profile

Joined: Mon Dec 06, 2010 18:34
Posts: 9
Post Re: Backup ntfs partition
I have attr-2.4.43 and in our production we use ALTLinux (same as CentOS but from motherland company ;)
I've seen that patches, tnx again.
I added to script coping time attributes (system.ntfs_times). Work fine.
Big tnx for help.


Tue Dec 14, 2010 20:59
Profile

Joined: Wed Mar 09, 2011 19:15
Posts: 1
Post Re: Backup ntfs partition
Biriukov wrote:
I have attr-2.4.43 and in our production we use ALTLinux (same as CentOS but from motherland company ;)
I've seen that patches, tnx again.
I added to script coping time attributes (system.ntfs_times). Work fine.
Big tnx for help.

Hi, I'd like to try out your scripts with the latest addition you've made (saving of timestamps). Would it be possible for you to make it available for download as well? Thanks in advance.


Wed Mar 09, 2011 19:20
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ] 


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Original forum style by Vjacheslav Trushkin.