mv: Directory not empty

Though its man page doesn't document it, mv will refuse to rename a directory to another directory if the target directory contains files. This is a good thing in your case because you turn out to want to merge the content of the source into the target, which mv will not do.

Use rsync -a backup/ backupArchives/ instead. After that rm -rf backup/*.

Instead of using rsync, you also can do the classical

(cd backup && tar c .) | (cd backupArchives && tar xf -)

which earns you more geek points.


Quick and dirty, if you know what you are doing:

cp -r ./backup/* ./backupArchives && rm -R ./backup/*

After the directory you moving you need * (represents any text or number). For example:

mv /var/www/* /recovery/wwwrecovery/

thats all, if you moving files, than you move as:

mv /var/www/index.php /recovery/index.php

Another way is to pack that folder content by using tar:

tar -cvzpf backup.tar.gz /var/www 

Then move it lie any other file. Also I recommend this step because tar compresses it and make it smaller in size.

To extract the files to another folder use

tar -xvzpf /var/www/

If you need to copy to a location you don't own, make sure to prepend your command with the sudo command after whichever option you decide to use.

sudo tar -cvzpf backup.tar.gz /var/www/

Tags:

Directory

Mv