P
P
pqgg7nwkd42018-08-30 19:04:02
linux
pqgg7nwkd4, 2018-08-30 19:04:02

How to override one of the folders when using rsync?

There is a file structure like this:

front/
front/1.txt

back/
back/scripts/
back/.../
back/front/
back/front/2.txt

You need to rsync to the server so that it looks like this:
scripts/
.../
front/
front/1.txt

Those. instead of the back/front/ folder, the front/ folder was used.
Folders cannot be renamed.
Due to the fact that the front folders are named the same and should be in the root, it’s impossible to pick up the rsync parameters. This command synchronizes both front folders, which is not necessary:
rsync \
--archive \
--delete --delete-excluded --delete-after --ignore-errors --force \
--compress \
--partial -i \
-e "ssh" \
/path/to/back/ \
/path/to/front \
[email protected]:/path/to/back/

How to be?
I think you can somehow write an insert instead of /path/to/back/, which will list all nested folders and files there, except for front/, but there is not enough knowledge of bash and Linux.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pqgg7nwkd4, 2018-08-31
@pqgg7nwkd4

Did something like this:

rsync \
--archive \
--delete --delete-excluded --delete-after --ignore-errors --force \
--compress \
--partial -i \
-e "ssh" \
`find /path/to/back/ -maxdepth 1 -mindepth 1 | grep -v /front` \
/path/to/front \
[email protected]:/path/to/back/

Works as it should

K
ky0, 2018-08-30
@ky0

Synchronize in several parts, first with the same directory structure, then with a different one? If I understand you correctly, of course...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question