Aris Moratalla's picture

Hi guys!

I got a TKL Fileserver up and running for almost 6 months now. I am using a cron job to create a local backup of samba shares. I have noticed that the Date Modified of created backup files is the date when the files were created.

cron job: cp -R /mnt/fileserver/File-server /mnt/backup

I'm just wondering if I could leave the Dated Modified of the backup files same with the original files.

Thanks in advance!

Jeremy Davis's picture

No doubt there is a way. Perhaps if you tar the files first (not sure if that'd work?) Another work around may be to rename the file to reflect the backup. Just remember that TKL is Ubuntu under the hood so anything that applies to Ubuntu (and to some extent Debian too) should apply to TKL.

Aris Moratalla's picture

Thanks for the reply Jed!

I will try using tar balls.

bobmct's picture

Sorry I'm so late (just signed up).

In linux use the "-p' (lower case p) option to retain the date/time on the destination.

ex:  cp -p sourcefile targetfile

Aris Moratalla's picture

Thanks bob! will try it.

Aris Moratalla's picture

Hi Bob!

It's not working. I also check on cp --help... there is no -c described as argument.

I have the command on my cron job.

cp -R /mnt/fileserver/FS_Backup/File-server /mnt/backup

Hope ou can help.


Don Sanderson's picture

in the post by bobmct the '-p' option should preserve ownership and timestamp.

From the man page for cp:

-p     same as --preserve=mode,ownership,timestamps

Ryszard Czerminski's picture

According to "cp" documentation -p should preserve file attributes, but it does not work for me (maybe it is some peculiarity/bug on Mac ?).

However "rsync -az" works like a dream.

Jeremy Davis's picture

TurnKey Linux is based on Debian so has GNU versions of tools such as cp. I suspect that as Mac is a proprietary OS, that it doesn't use the GNU variants of these tools so the options probably differ.
Aris Moratalla's picture

sorry...may bad. I thought it was -c.

So in my command.. is it cp -R -c?

Don Sanderson's picture

'cp -Rp' or 'cp -R -p'

As far as I know there is no -c option.

Aris Moratalla's picture

I am getting these error...


cp -Rp /mnt/fileserver/FS_Backup/File-server/adm/201 /mnt/backup
cp: cannot stat `/mnt/fileserver/FS_Backup/File-server/adm/201': No such file or directory
cp -R -p /mnt/fileserver/FS_Backup/File-server/adm/201 /mnt/backup
cp: cannot stat `/mnt/fileserver/FS_Backup/File-server/adm/201': No such file or directory
Aris Moratalla's picture

I was able to sort this out.

case sensitivity caused the error.

cp -R -p /mnt/fileserver/FS_Backup/File-server/ADM/201 /mnt/backup.

Thank you so much Don Sanderson, bob and Jed!

Don Sanderson's picture

You posted as I was writing this, glad you got it sorted. :-)


You will have to examine your file system and see what is wrong with the path:


CP can't find, or understand, what you are asking of it.

Aris Moratalla's picture

Hi again Don!

I know I should create a new topic for this question- but I just want to ask on how I can make 2 local fileserver synchronize... from the filesystem to the mounted partions. What I am trying to do is make an exact replica of my current TKL Fileserver which will synchronize with the original at the end of the day.

I have tried TKLBAM but it did not work for me because the internet here is not that good (the disconnects like every 15 minutes, not to mention a very low bandwidth).

Thanks in advance!

Don Sanderson's picture

Make a local backup from the 'original'.

Restore to the 'clone' from that backup.

Add new comment