Are Documents/. and Documents/ the same?
I use it without the dot… it copies all the files including dot files.
Not the same as Documents/*
What does the dot do? I thought that you omit the trailing slash when transferring the actual directory. So would the /. just transfer the contents so that you do not end up with $DESTINATION/DESTINATION folders at the target?
Thanks,
Sheila
I think so. / and /. seem to have the same effect… ie they transfer the contents not the folder.
We should wait and see what @daniel.m.tripp says.
/* is different… it transfers the contents too, but omits dot files.
Applies to tar
too, not just rsync
Essentially “Documents/” and “Documents/.” are the same thing…
But I just append the “dot” “to be sure, to be sure”…
So “cp -r $SOURCE/. $DESTINATION/.
” ensures I’m copying the contents of one to the other - not the “object” itself… It’s probably overkill I agree…
In this case “.” means the contents of the dir… and assumes $DESTINATION exists…
And yes - pretty much the same case for cp (-r), tar and rsync - probably cpio too (haven’t used that for decades now - but - DEB files are actually cpio archives)… these days I only use tar and rsync - I’ve done benchmarks - tar through a pipe, is always faster than rsync…
Lets say we’ve got a folder called Important, we want to copy it’s contents to somewhere else (e.g. to a mounted NFS filesystem) - e.g. bkup-important (NFS mounted at /mnt/bk-important). First time round, I’d use tar to “populate it”.
cd Important ; tar cvpf - . | (cd /mnt/bk-important ; tar xvpf -)
Then a tad later - when I want to refresh it with more current data :
rsync -av Important/. /mnt/bk-important/.
I’ve verified tar is faster - when migrating some 30 TB of customer data from one NAS (NetApp) to new NAS (Nutanix AFS).
There may be a case to be made for using compression - e.g. over a slow link :
cd Important ; tar czvpf - . | (cd /mnt/bk-important ; tar xzvpf -)
Then a tad later - when I want to refresh it with more current data :
rsync -avz Important/. /mnt/bk-important/.
Both tar and rsync are inherently more bullet-proof than “cp”. I’ve found cpio nearly as good - but as mentioned above haven’t used cpio for decades…
But probably easier to just use rsync in the first place - as that pipe to STD-IN can get a bit fiddly and easy to mess up…
It is called ritual
.
It helps the world to function, including the computer world.
Yes
If we had rsh
it would also be the best option across machines.
tar -cf - -C srcdir . | rsh otherhost tar xpf - -C destdir
used to be common practice
Thanks for that , it is a good summary of how to copy stuff.
@daniel.m.tripp thanks for that great explanation. I have put those steps in my Linux notebook as it was easier to understand than some articles I’ve read.
Although I knew what tar was, I did not know how to use it and that will definitely help on getting over 500 gb of files to the new nfs-server.
Thanks,
Sheila
It’s also so I know the result… e.g. if either side (folder) doesn’t exist - it won’t run… that’s good… Means I did something wrong and need to rethink it… e.g. create the destination… find out if I have permissions etc…