Trinix Quick Tip!
Using Rsync With GUI File Manager to Preserve Folder Timestamps
Copy Folder Structure While Maintaining Timestamps
This article will show you how to preserve time stamps of folders when using a GUI based file manager to copy a set of files/folders to another location.
Often GUI based file managers in Linux don’t preserve modification and creation time stamps on folders.
For example, if you copy a set of files and folders to a new location, all the folders will have the current date and time set as the timestamp for all the folders in the destination.
This is kind of a awkward fix/hack, but it works. What we’re going to do is create the folder structure first using rsync, then we’ll use a GUI based file manager to copy all the files into the folder structure.
Using GUI based file managers have the benefit of displaying more accurate feedback in terms of the progress and estimated transfer time.
The following is the basic structure to use with the rsync command. Just substitute your source and destination paths.
rsync -a --include '*/' --exclude '*' /srv/nfs/Business/DevAssets /mnt/mainShare/Business --progress
*Note: Don’t name the main folder that your copying from source. In this example, the ‘DevAssets’ folder is the source folder that we are copying to the destination so you don’t want to include the ‘DevAssets’ name in the destination path.
Doing so will result in a extra nested directory in your folder structure. For example, if you did include the ‘DevAssets’ name in the destination path, you would end up with the following path: /mnt/mainShare/Business/DevAssets/DevAssets.
This would be less clumsy if this were incorporated into a script or if there was some way to substitute the default folder creation method used in Dolphin for instance, with this rsync command.
If you think about it, that what Dolphin does anyway. If you watch the notification pop-up when copying a set of files and folders to a new location, Dolphin creates the directory structure first, then copies the files into the newly created structure.
This is why we loose our time stamps. Dolphin creates the folders in the destination location instead of copying the folders from the source along with all their properties.
If anyone knows a easier way to preserve time stamps when copying a set of folders to a new location, please leave a comment illustrating the method.
Like wise, if there’s a GUI based File manager that you’re aware of that does preserve the folder properties, please contribute your find by listing it in the comments below.
Also check out a video I put together highlighting the issue and walking through the process: Trinix Media YouTube Channel
Thanks for checking out our blog and stay safe out there.