cp losing file's metadata

Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
I have an Asustor NAS that runs on Linux; I don't know what distro they use.
I'm able to log in it using SSH and use all Shell commands. Internal Volume uses ext2, and external USB HDs use NTFS.
When I try to use cp command to copy any file around, that file's date metadata is changed to current datetime.
In example, if I use Windows to copy the file from SMB and the file was modified in 2007, the new file is marked as created now in 2017 but modified in 2007. But with Linux cp command its modified date is changed to 2017 too.
This modified date is very relevant to me because it allows me to sort files on Windows Explore by their modified date. If it's overridden, I'm unable to sort and they all seem to have been created now. I also use modified date to know when I acquired some rare old files.
Is there any parameter I can use in cp command to preserve original file metadata?
Update: I tried cp --preserve=timestamps but it didn't work, it printed:
cp: unrecognized option '--preserve=timestamps'
BusyBox v1.19.3 (2017-03-22 17:23:49 CST) multi-call binary.
Usage: cp [OPTIONS] SOURCE DEST
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
-a Same as -dpR
-R,-r Recurse
-d,-P Preserve symlinks (default if -R)
-L Follow all symlinks
-H Follow symlinks on command line
-p Preserve file attributes if possible
-f Overwrite
-i Prompt before overwrite
-l,-s Create (sym)links
If I try just -p it says cp: can't preserve permissions of '...': Operation not permitted, but as far as I've tested, timestamps are being preserved.
linux-kernel date cp file-copy file-metadata
add a comment |Â
up vote
6
down vote
favorite
I have an Asustor NAS that runs on Linux; I don't know what distro they use.
I'm able to log in it using SSH and use all Shell commands. Internal Volume uses ext2, and external USB HDs use NTFS.
When I try to use cp command to copy any file around, that file's date metadata is changed to current datetime.
In example, if I use Windows to copy the file from SMB and the file was modified in 2007, the new file is marked as created now in 2017 but modified in 2007. But with Linux cp command its modified date is changed to 2017 too.
This modified date is very relevant to me because it allows me to sort files on Windows Explore by their modified date. If it's overridden, I'm unable to sort and they all seem to have been created now. I also use modified date to know when I acquired some rare old files.
Is there any parameter I can use in cp command to preserve original file metadata?
Update: I tried cp --preserve=timestamps but it didn't work, it printed:
cp: unrecognized option '--preserve=timestamps'
BusyBox v1.19.3 (2017-03-22 17:23:49 CST) multi-call binary.
Usage: cp [OPTIONS] SOURCE DEST
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
-a Same as -dpR
-R,-r Recurse
-d,-P Preserve symlinks (default if -R)
-L Follow all symlinks
-H Follow symlinks on command line
-p Preserve file attributes if possible
-f Overwrite
-i Prompt before overwrite
-l,-s Create (sym)links
If I try just -p it says cp: can't preserve permissions of '...': Operation not permitted, but as far as I've tested, timestamps are being preserved.
linux-kernel date cp file-copy file-metadata
3
Other than--preserve?
â Ignacio Vazquez-Abrams
Nov 6 '17 at 16:07
Resolution:-pworks. The error message is probably related to me copying files from internal ext4 HDs to external NTFS HDs. Anyway I don't need to preserve permissions, only timestamps, and in all tests I did timestamps are being properly preserved. I just ignore the permissions error messages and run md5 to assure files' integrity. Basicly I usecp -pR.
â Hikari
Nov 17 '17 at 13:54
rsync -rltDvu --modify-window=1will do the integrity verification for you.
â Ignacio Vazquez-Abrams
Nov 17 '17 at 16:39
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
I have an Asustor NAS that runs on Linux; I don't know what distro they use.
I'm able to log in it using SSH and use all Shell commands. Internal Volume uses ext2, and external USB HDs use NTFS.
When I try to use cp command to copy any file around, that file's date metadata is changed to current datetime.
In example, if I use Windows to copy the file from SMB and the file was modified in 2007, the new file is marked as created now in 2017 but modified in 2007. But with Linux cp command its modified date is changed to 2017 too.
This modified date is very relevant to me because it allows me to sort files on Windows Explore by their modified date. If it's overridden, I'm unable to sort and they all seem to have been created now. I also use modified date to know when I acquired some rare old files.
Is there any parameter I can use in cp command to preserve original file metadata?
Update: I tried cp --preserve=timestamps but it didn't work, it printed:
cp: unrecognized option '--preserve=timestamps'
BusyBox v1.19.3 (2017-03-22 17:23:49 CST) multi-call binary.
Usage: cp [OPTIONS] SOURCE DEST
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
-a Same as -dpR
-R,-r Recurse
-d,-P Preserve symlinks (default if -R)
-L Follow all symlinks
-H Follow symlinks on command line
-p Preserve file attributes if possible
-f Overwrite
-i Prompt before overwrite
-l,-s Create (sym)links
If I try just -p it says cp: can't preserve permissions of '...': Operation not permitted, but as far as I've tested, timestamps are being preserved.
linux-kernel date cp file-copy file-metadata
I have an Asustor NAS that runs on Linux; I don't know what distro they use.
I'm able to log in it using SSH and use all Shell commands. Internal Volume uses ext2, and external USB HDs use NTFS.
When I try to use cp command to copy any file around, that file's date metadata is changed to current datetime.
In example, if I use Windows to copy the file from SMB and the file was modified in 2007, the new file is marked as created now in 2017 but modified in 2007. But with Linux cp command its modified date is changed to 2017 too.
This modified date is very relevant to me because it allows me to sort files on Windows Explore by their modified date. If it's overridden, I'm unable to sort and they all seem to have been created now. I also use modified date to know when I acquired some rare old files.
Is there any parameter I can use in cp command to preserve original file metadata?
Update: I tried cp --preserve=timestamps but it didn't work, it printed:
cp: unrecognized option '--preserve=timestamps'
BusyBox v1.19.3 (2017-03-22 17:23:49 CST) multi-call binary.
Usage: cp [OPTIONS] SOURCE DEST
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
-a Same as -dpR
-R,-r Recurse
-d,-P Preserve symlinks (default if -R)
-L Follow all symlinks
-H Follow symlinks on command line
-p Preserve file attributes if possible
-f Overwrite
-i Prompt before overwrite
-l,-s Create (sym)links
If I try just -p it says cp: can't preserve permissions of '...': Operation not permitted, but as far as I've tested, timestamps are being preserved.
linux-kernel date cp file-copy file-metadata
edited Nov 12 '17 at 14:50
Jeff Schaller
32k849109
32k849109
asked Nov 6 '17 at 16:04
Hikari
1335
1335
3
Other than--preserve?
â Ignacio Vazquez-Abrams
Nov 6 '17 at 16:07
Resolution:-pworks. The error message is probably related to me copying files from internal ext4 HDs to external NTFS HDs. Anyway I don't need to preserve permissions, only timestamps, and in all tests I did timestamps are being properly preserved. I just ignore the permissions error messages and run md5 to assure files' integrity. Basicly I usecp -pR.
â Hikari
Nov 17 '17 at 13:54
rsync -rltDvu --modify-window=1will do the integrity verification for you.
â Ignacio Vazquez-Abrams
Nov 17 '17 at 16:39
add a comment |Â
3
Other than--preserve?
â Ignacio Vazquez-Abrams
Nov 6 '17 at 16:07
Resolution:-pworks. The error message is probably related to me copying files from internal ext4 HDs to external NTFS HDs. Anyway I don't need to preserve permissions, only timestamps, and in all tests I did timestamps are being properly preserved. I just ignore the permissions error messages and run md5 to assure files' integrity. Basicly I usecp -pR.
â Hikari
Nov 17 '17 at 13:54
rsync -rltDvu --modify-window=1will do the integrity verification for you.
â Ignacio Vazquez-Abrams
Nov 17 '17 at 16:39
3
3
Other than
--preserve?â Ignacio Vazquez-Abrams
Nov 6 '17 at 16:07
Other than
--preserve?â Ignacio Vazquez-Abrams
Nov 6 '17 at 16:07
Resolution:
-p works. The error message is probably related to me copying files from internal ext4 HDs to external NTFS HDs. Anyway I don't need to preserve permissions, only timestamps, and in all tests I did timestamps are being properly preserved. I just ignore the permissions error messages and run md5 to assure files' integrity. Basicly I use cp -pR.â Hikari
Nov 17 '17 at 13:54
Resolution:
-p works. The error message is probably related to me copying files from internal ext4 HDs to external NTFS HDs. Anyway I don't need to preserve permissions, only timestamps, and in all tests I did timestamps are being properly preserved. I just ignore the permissions error messages and run md5 to assure files' integrity. Basicly I use cp -pR.â Hikari
Nov 17 '17 at 13:54
rsync -rltDvu --modify-window=1 will do the integrity verification for you.â Ignacio Vazquez-Abrams
Nov 17 '17 at 16:39
rsync -rltDvu --modify-window=1 will do the integrity verification for you.â Ignacio Vazquez-Abrams
Nov 17 '17 at 16:39
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
11
down vote
accepted
If you use man cp to read the manual page for the copy command you'll find the -p and --preserve flags.
-psame as--preserve=mode,ownership,timestamps
and
--preserve[=ATTR_LIST]preserve the specified attributes (default:mode,ownership,timestamps), if possible additional attributes:context,links,xattr,all
What this boils down to is that you should use cp -p instead of just cp.
1
sometimescp -ais useful too...
â Basile Starynkevitch
Nov 6 '17 at 16:37
Yes. I use-a(sometimes with-l) for recursive copying, and-palmost always otherwise. @BasileStarynkevitch
â roaima
Nov 6 '17 at 16:54
Note thattimestampspreservesmtimeandatime, but AFAIK it's not possible to preservectime.
â Barmar
Nov 6 '17 at 22:47
Sorry for the late reply. It didn't work for me. Updated the question.
â Hikari
Nov 8 '17 at 1:55
add a comment |Â
up vote
1
down vote
I think there are a couple of observations worth pointing out.
You say that you're not sure what distribution you're using, but in your update you included output that identified your distribution as being BusyBox v1.19.3. Looking at the Developer Guide for the Asustor NAS confirms that the OS in question is BusyBox.
The answer posted by @roaima quotes the man page for the cp command. This makes sense in general, but maybe not in this case.
BusyBox is a minimalistic Linux OS designed for embedded devices and it's a little bit of a different environment than the more popular Linux flavors that most people are probably used to. In particular there are probably no man pages on your NAS and the commands may have slightly different features, behavior, and syntax. Here is the documentation for BusyBox:
- BusyBox Manual Page
And here is the entry for the cp command on BusyBox:
cp
cp [OPTIONS] SOURCE DEST
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
Options:
-a Same as -dpR
-d,-P Preserve links
-H,-L Dereference all symlinks (default)
-p Preserve file attributes if possible
-f Force overwrite
-i Prompt before overwrite
-R,-r Recurse
-l,-s Create (sym)links
We can see that the -p option flag is still there and has the same semantics as it usually does, although it lacks the more flexible syntax available on more full-featured distributions:
--preserve[=ATTR_LIST]
This is consistent with the usage message that you got when trying to run the cp command with the --preserve flag.
Another option to try, since you say that the -p flag isn't working, would be to copy the file over without the -p flag and then use the touch command to update the modification time, e.g.:
root@busybox:~# cp original_file new_file
root@busybox:~# touch -r original_file new_file
If this doesn't work then you might want to update your question to include the error message that you get. You might also want to update your question to include the properties of the files you're trying to copy, the locations you're trying to copy them from and to, and the user that you're running, the exact commands that you're using, and the user you're logged in as when running these commands.
That said, I suspect that your cp -p command might be generating a permissions-related error because you're copying across mounted volumes and the file owner exists on one volume but not the other (or something similar to that).
Thanks a lot for the detailed info. I didn't know about BusyBox distro, so I didn't notice it. Good to know what distro I'm running. I added a comment to my question explaining the resolution.
â Hikari
Nov 17 '17 at 13:55
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
11
down vote
accepted
If you use man cp to read the manual page for the copy command you'll find the -p and --preserve flags.
-psame as--preserve=mode,ownership,timestamps
and
--preserve[=ATTR_LIST]preserve the specified attributes (default:mode,ownership,timestamps), if possible additional attributes:context,links,xattr,all
What this boils down to is that you should use cp -p instead of just cp.
1
sometimescp -ais useful too...
â Basile Starynkevitch
Nov 6 '17 at 16:37
Yes. I use-a(sometimes with-l) for recursive copying, and-palmost always otherwise. @BasileStarynkevitch
â roaima
Nov 6 '17 at 16:54
Note thattimestampspreservesmtimeandatime, but AFAIK it's not possible to preservectime.
â Barmar
Nov 6 '17 at 22:47
Sorry for the late reply. It didn't work for me. Updated the question.
â Hikari
Nov 8 '17 at 1:55
add a comment |Â
up vote
11
down vote
accepted
If you use man cp to read the manual page for the copy command you'll find the -p and --preserve flags.
-psame as--preserve=mode,ownership,timestamps
and
--preserve[=ATTR_LIST]preserve the specified attributes (default:mode,ownership,timestamps), if possible additional attributes:context,links,xattr,all
What this boils down to is that you should use cp -p instead of just cp.
1
sometimescp -ais useful too...
â Basile Starynkevitch
Nov 6 '17 at 16:37
Yes. I use-a(sometimes with-l) for recursive copying, and-palmost always otherwise. @BasileStarynkevitch
â roaima
Nov 6 '17 at 16:54
Note thattimestampspreservesmtimeandatime, but AFAIK it's not possible to preservectime.
â Barmar
Nov 6 '17 at 22:47
Sorry for the late reply. It didn't work for me. Updated the question.
â Hikari
Nov 8 '17 at 1:55
add a comment |Â
up vote
11
down vote
accepted
up vote
11
down vote
accepted
If you use man cp to read the manual page for the copy command you'll find the -p and --preserve flags.
-psame as--preserve=mode,ownership,timestamps
and
--preserve[=ATTR_LIST]preserve the specified attributes (default:mode,ownership,timestamps), if possible additional attributes:context,links,xattr,all
What this boils down to is that you should use cp -p instead of just cp.
If you use man cp to read the manual page for the copy command you'll find the -p and --preserve flags.
-psame as--preserve=mode,ownership,timestamps
and
--preserve[=ATTR_LIST]preserve the specified attributes (default:mode,ownership,timestamps), if possible additional attributes:context,links,xattr,all
What this boils down to is that you should use cp -p instead of just cp.
answered Nov 6 '17 at 16:28
roaima
39.9k546109
39.9k546109
1
sometimescp -ais useful too...
â Basile Starynkevitch
Nov 6 '17 at 16:37
Yes. I use-a(sometimes with-l) for recursive copying, and-palmost always otherwise. @BasileStarynkevitch
â roaima
Nov 6 '17 at 16:54
Note thattimestampspreservesmtimeandatime, but AFAIK it's not possible to preservectime.
â Barmar
Nov 6 '17 at 22:47
Sorry for the late reply. It didn't work for me. Updated the question.
â Hikari
Nov 8 '17 at 1:55
add a comment |Â
1
sometimescp -ais useful too...
â Basile Starynkevitch
Nov 6 '17 at 16:37
Yes. I use-a(sometimes with-l) for recursive copying, and-palmost always otherwise. @BasileStarynkevitch
â roaima
Nov 6 '17 at 16:54
Note thattimestampspreservesmtimeandatime, but AFAIK it's not possible to preservectime.
â Barmar
Nov 6 '17 at 22:47
Sorry for the late reply. It didn't work for me. Updated the question.
â Hikari
Nov 8 '17 at 1:55
1
1
sometimes
cp -a is useful too...â Basile Starynkevitch
Nov 6 '17 at 16:37
sometimes
cp -a is useful too...â Basile Starynkevitch
Nov 6 '17 at 16:37
Yes. I use
-a (sometimes with -l) for recursive copying, and -p almost always otherwise. @BasileStarynkevitchâ roaima
Nov 6 '17 at 16:54
Yes. I use
-a (sometimes with -l) for recursive copying, and -p almost always otherwise. @BasileStarynkevitchâ roaima
Nov 6 '17 at 16:54
Note that
timestamps preserves mtime and atime, but AFAIK it's not possible to preserve ctime.â Barmar
Nov 6 '17 at 22:47
Note that
timestamps preserves mtime and atime, but AFAIK it's not possible to preserve ctime.â Barmar
Nov 6 '17 at 22:47
Sorry for the late reply. It didn't work for me. Updated the question.
â Hikari
Nov 8 '17 at 1:55
Sorry for the late reply. It didn't work for me. Updated the question.
â Hikari
Nov 8 '17 at 1:55
add a comment |Â
up vote
1
down vote
I think there are a couple of observations worth pointing out.
You say that you're not sure what distribution you're using, but in your update you included output that identified your distribution as being BusyBox v1.19.3. Looking at the Developer Guide for the Asustor NAS confirms that the OS in question is BusyBox.
The answer posted by @roaima quotes the man page for the cp command. This makes sense in general, but maybe not in this case.
BusyBox is a minimalistic Linux OS designed for embedded devices and it's a little bit of a different environment than the more popular Linux flavors that most people are probably used to. In particular there are probably no man pages on your NAS and the commands may have slightly different features, behavior, and syntax. Here is the documentation for BusyBox:
- BusyBox Manual Page
And here is the entry for the cp command on BusyBox:
cp
cp [OPTIONS] SOURCE DEST
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
Options:
-a Same as -dpR
-d,-P Preserve links
-H,-L Dereference all symlinks (default)
-p Preserve file attributes if possible
-f Force overwrite
-i Prompt before overwrite
-R,-r Recurse
-l,-s Create (sym)links
We can see that the -p option flag is still there and has the same semantics as it usually does, although it lacks the more flexible syntax available on more full-featured distributions:
--preserve[=ATTR_LIST]
This is consistent with the usage message that you got when trying to run the cp command with the --preserve flag.
Another option to try, since you say that the -p flag isn't working, would be to copy the file over without the -p flag and then use the touch command to update the modification time, e.g.:
root@busybox:~# cp original_file new_file
root@busybox:~# touch -r original_file new_file
If this doesn't work then you might want to update your question to include the error message that you get. You might also want to update your question to include the properties of the files you're trying to copy, the locations you're trying to copy them from and to, and the user that you're running, the exact commands that you're using, and the user you're logged in as when running these commands.
That said, I suspect that your cp -p command might be generating a permissions-related error because you're copying across mounted volumes and the file owner exists on one volume but not the other (or something similar to that).
Thanks a lot for the detailed info. I didn't know about BusyBox distro, so I didn't notice it. Good to know what distro I'm running. I added a comment to my question explaining the resolution.
â Hikari
Nov 17 '17 at 13:55
add a comment |Â
up vote
1
down vote
I think there are a couple of observations worth pointing out.
You say that you're not sure what distribution you're using, but in your update you included output that identified your distribution as being BusyBox v1.19.3. Looking at the Developer Guide for the Asustor NAS confirms that the OS in question is BusyBox.
The answer posted by @roaima quotes the man page for the cp command. This makes sense in general, but maybe not in this case.
BusyBox is a minimalistic Linux OS designed for embedded devices and it's a little bit of a different environment than the more popular Linux flavors that most people are probably used to. In particular there are probably no man pages on your NAS and the commands may have slightly different features, behavior, and syntax. Here is the documentation for BusyBox:
- BusyBox Manual Page
And here is the entry for the cp command on BusyBox:
cp
cp [OPTIONS] SOURCE DEST
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
Options:
-a Same as -dpR
-d,-P Preserve links
-H,-L Dereference all symlinks (default)
-p Preserve file attributes if possible
-f Force overwrite
-i Prompt before overwrite
-R,-r Recurse
-l,-s Create (sym)links
We can see that the -p option flag is still there and has the same semantics as it usually does, although it lacks the more flexible syntax available on more full-featured distributions:
--preserve[=ATTR_LIST]
This is consistent with the usage message that you got when trying to run the cp command with the --preserve flag.
Another option to try, since you say that the -p flag isn't working, would be to copy the file over without the -p flag and then use the touch command to update the modification time, e.g.:
root@busybox:~# cp original_file new_file
root@busybox:~# touch -r original_file new_file
If this doesn't work then you might want to update your question to include the error message that you get. You might also want to update your question to include the properties of the files you're trying to copy, the locations you're trying to copy them from and to, and the user that you're running, the exact commands that you're using, and the user you're logged in as when running these commands.
That said, I suspect that your cp -p command might be generating a permissions-related error because you're copying across mounted volumes and the file owner exists on one volume but not the other (or something similar to that).
Thanks a lot for the detailed info. I didn't know about BusyBox distro, so I didn't notice it. Good to know what distro I'm running. I added a comment to my question explaining the resolution.
â Hikari
Nov 17 '17 at 13:55
add a comment |Â
up vote
1
down vote
up vote
1
down vote
I think there are a couple of observations worth pointing out.
You say that you're not sure what distribution you're using, but in your update you included output that identified your distribution as being BusyBox v1.19.3. Looking at the Developer Guide for the Asustor NAS confirms that the OS in question is BusyBox.
The answer posted by @roaima quotes the man page for the cp command. This makes sense in general, but maybe not in this case.
BusyBox is a minimalistic Linux OS designed for embedded devices and it's a little bit of a different environment than the more popular Linux flavors that most people are probably used to. In particular there are probably no man pages on your NAS and the commands may have slightly different features, behavior, and syntax. Here is the documentation for BusyBox:
- BusyBox Manual Page
And here is the entry for the cp command on BusyBox:
cp
cp [OPTIONS] SOURCE DEST
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
Options:
-a Same as -dpR
-d,-P Preserve links
-H,-L Dereference all symlinks (default)
-p Preserve file attributes if possible
-f Force overwrite
-i Prompt before overwrite
-R,-r Recurse
-l,-s Create (sym)links
We can see that the -p option flag is still there and has the same semantics as it usually does, although it lacks the more flexible syntax available on more full-featured distributions:
--preserve[=ATTR_LIST]
This is consistent with the usage message that you got when trying to run the cp command with the --preserve flag.
Another option to try, since you say that the -p flag isn't working, would be to copy the file over without the -p flag and then use the touch command to update the modification time, e.g.:
root@busybox:~# cp original_file new_file
root@busybox:~# touch -r original_file new_file
If this doesn't work then you might want to update your question to include the error message that you get. You might also want to update your question to include the properties of the files you're trying to copy, the locations you're trying to copy them from and to, and the user that you're running, the exact commands that you're using, and the user you're logged in as when running these commands.
That said, I suspect that your cp -p command might be generating a permissions-related error because you're copying across mounted volumes and the file owner exists on one volume but not the other (or something similar to that).
I think there are a couple of observations worth pointing out.
You say that you're not sure what distribution you're using, but in your update you included output that identified your distribution as being BusyBox v1.19.3. Looking at the Developer Guide for the Asustor NAS confirms that the OS in question is BusyBox.
The answer posted by @roaima quotes the man page for the cp command. This makes sense in general, but maybe not in this case.
BusyBox is a minimalistic Linux OS designed for embedded devices and it's a little bit of a different environment than the more popular Linux flavors that most people are probably used to. In particular there are probably no man pages on your NAS and the commands may have slightly different features, behavior, and syntax. Here is the documentation for BusyBox:
- BusyBox Manual Page
And here is the entry for the cp command on BusyBox:
cp
cp [OPTIONS] SOURCE DEST
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
Options:
-a Same as -dpR
-d,-P Preserve links
-H,-L Dereference all symlinks (default)
-p Preserve file attributes if possible
-f Force overwrite
-i Prompt before overwrite
-R,-r Recurse
-l,-s Create (sym)links
We can see that the -p option flag is still there and has the same semantics as it usually does, although it lacks the more flexible syntax available on more full-featured distributions:
--preserve[=ATTR_LIST]
This is consistent with the usage message that you got when trying to run the cp command with the --preserve flag.
Another option to try, since you say that the -p flag isn't working, would be to copy the file over without the -p flag and then use the touch command to update the modification time, e.g.:
root@busybox:~# cp original_file new_file
root@busybox:~# touch -r original_file new_file
If this doesn't work then you might want to update your question to include the error message that you get. You might also want to update your question to include the properties of the files you're trying to copy, the locations you're trying to copy them from and to, and the user that you're running, the exact commands that you're using, and the user you're logged in as when running these commands.
That said, I suspect that your cp -p command might be generating a permissions-related error because you're copying across mounted volumes and the file owner exists on one volume but not the other (or something similar to that).
edited Nov 8 '17 at 4:04
answered Nov 8 '17 at 3:46
igal
4,830930
4,830930
Thanks a lot for the detailed info. I didn't know about BusyBox distro, so I didn't notice it. Good to know what distro I'm running. I added a comment to my question explaining the resolution.
â Hikari
Nov 17 '17 at 13:55
add a comment |Â
Thanks a lot for the detailed info. I didn't know about BusyBox distro, so I didn't notice it. Good to know what distro I'm running. I added a comment to my question explaining the resolution.
â Hikari
Nov 17 '17 at 13:55
Thanks a lot for the detailed info. I didn't know about BusyBox distro, so I didn't notice it. Good to know what distro I'm running. I added a comment to my question explaining the resolution.
â Hikari
Nov 17 '17 at 13:55
Thanks a lot for the detailed info. I didn't know about BusyBox distro, so I didn't notice it. Good to know what distro I'm running. I added a comment to my question explaining the resolution.
â Hikari
Nov 17 '17 at 13:55
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402862%2fcp-losing-files-metadata%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
3
Other than
--preserve?â Ignacio Vazquez-Abrams
Nov 6 '17 at 16:07
Resolution:
-pworks. The error message is probably related to me copying files from internal ext4 HDs to external NTFS HDs. Anyway I don't need to preserve permissions, only timestamps, and in all tests I did timestamps are being properly preserved. I just ignore the permissions error messages and run md5 to assure files' integrity. Basicly I usecp -pR.â Hikari
Nov 17 '17 at 13:54
rsync -rltDvu --modify-window=1will do the integrity verification for you.â Ignacio Vazquez-Abrams
Nov 17 '17 at 16:39