in the gitlab-ci for our automatic deployment pipeline, we need to move all files and folders of the old application into a folder "_backup" in the same root directory.
This is our approach: mv /mnt/test.local/* /mnt/test.local/_backup
But the error messages are: mv: can't rename '/mnt/test.local/favicon.ico': No such file or directory
I think the problem is that I can not move all files and folders (including "_backup"-folder) into the "_backup"-folder. I read about the extglob
shell options, but !(_backup)
is not working, is there another way?
Update : I tried @Kent's approach, but somehow it is not working. When I test it locally I get the following error but it works:
$ find ~/Workspace/testingmove/ -mindepth 1 -maxdepth 1 -path ~/Workspace/testingmove/_backup -prune -o -print|xargs -I{} mv {} -t ~/Workspace/testingmove/_backup
mv: rename /Users/wiesenberg/Workspace/testingmove//_backup to /Users/wiesenberg/Workspace/testingmove/_backup/_backup: Invalid argument
mv: rename -t to /Users/wiesenberg/Workspace/testingmove/_backup/-t: No such file or directory
And when I try it in the gitlab-ci, the following error accurs:
$ find /mnt/test.local/ -mindepth 1 -maxdepth 1 -path /mnt/test.local/_backup -prune -o -print|xargs -I{} mv {} -t /mnt/test.local/_backup/
mv: unrecognized option: t
BusyBox v1.31.1 () multi-call binary.
Usage: mv [-fin] SOURCE DEST
or: mv [-fin] SOURCE... DIRECTORY
Thanks, Marc
You can use find
to exclude the backup directory:
find /YourHome -mindepth 1 -path /YourHome/_backup -prune -o -print|xargs -I{} cp -r {} /YourHome/_backup
Replace the cp
command in xargs with mv
if you want to do "mv"
find /YourHome -mindepth 1 -maxdepth 1 -path /YourHome/_backup -prune -o -print|xargs -I{} mv {} -t /YourHome/_backup
My workaround is that I created a two subfolders and routed the Webserver to the subfolder.
- root
- _backup
- website
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.