Is there any advantage to Rsync moving files on the same machine?
I was reading how to install Magento on Digital Ocean Ubuntu 14.04 VPS. All files are on the server. the author says:
We will use
rsyncto transfer our Magento files there, sincersyncwill include important hidden files like.htaccess. Once the transfer is complete, we can clean up our home directory by deleting themagentofolder and archive there.sudo rsync -avP ~/magento/. /var/www/html/
rsyncwill safely copy all of the contents from the directory that you unpacked to the document root at/var/www/html/.
i've been using Linux for a long long time and never used Rsync to move files on the same machine, and never encoutered the problems mentioned by the author. Digital Ocean hires professional authors so there might be a point behind his claims.
Is there an advantage to using Rsync over mv or cp, when moving files on the same machine?
41 Answer
I assume the point is to transfer the content of magento to /var/www/html. That's to say, if we had:
magento
├── .bar
└── fooWe'd get:
html
├── .bar
└── fooThis is annoying, but not difficult, to accomplish this with mv. You'd have to use some form of find, or enable dotglob in bash, to include the .bar.
rsync is simpler.
With find:
find magento -mindepth 1 -maxdepth 1 -exec mv -t /var/www/html {} +With dotglob in bash:
shopt -s dotglob
mv magento/* /var/www/html 4