Есть ли способ скопировать папку на съемный носитель, но уже скопировал файлы и подпапки, отличные от файлов на съемном носителе?
Я часто использую следующую командную строку, чтобы проверить, что произойдет, «сухой запуск»,
sudo rsync -Havn source-dir/ target-dir
и следующую командную строку для выполните задание,
sudo rsync -Hav source-dir/ target-dir
Редактирование:
Я использую sudo при локальном запуске, чтобы иметь возможность сохранять права собственности и разрешения, что очень важно для системных файлов и файлы конфигурации. Если вы хотите сделать то же самое, используйте Linux-файловую систему, например ext4 на внешнем диске.
Если вы только «копируете файлы данных (документы, изображения, мультимедийные файлы ... ) вам не нужно беспокоиться о разрешениях и использовать более простую командную строку rsync
Изменить:
Обратите внимание на конечную косую черту. См.
man rsync
для получения подробной информации о концевой косой черте и параметрах (-H, -a, -v, -n и -t)
You use rsync in the same way you use rcp. You must specify a source and a des‐
tination, one of which may be remote.
Perhaps the best way to explain the syntax is with some examples:
rsync -t *.c foo:src/
This would transfer all files matching the pattern *.c from the current direc‐
tory to the directory src on the machine foo. If any of the files already exist
on the remote system then the rsync remote-update protocol is used to update the
file by sending only the differences in the data. Note that the expansion of
wildcards on the commandline (*.c) into a list of files is handled by the shell
before it runs rsync and not by rsync itself (exactly the same as all other
posix-style programs).
rsync -avz foo:src/bar /data/tmp
This would recursively transfer all files from the directory src/bar on the
machine foo into the /data/tmp/bar directory on the local machine. The files are
transferred in "archive" mode, which ensures that symbolic links, devices,
attributes, permissions, ownerships, etc. are preserved in the transfer. Addi‐
tionally, compression will be used to reduce the size of data portions of the
transfer.
rsync -avz foo:src/bar/ /data/tmp
A trailing slash on the source changes this behavior to avoid creating an addi‐
tional directory level at the destination. You can think of a trailing / on a
source as meaning "copy the contents of this directory" as opposed to "copy the
directory by name", but in both cases the attributes of the containing directory
are transferred to the containing directory on the destination. In other words,
each of the following commands copies the files in the same way, including their
setting of the attributes of /dest/foo:
rsync -av /src/foo /dest
rsync -av /src/foo/ /dest/foo
Note also that host and module references don’t require a trailing slash to copy
the contents of the default directory. For example, both of these copy the
remote directory’s contents into "/dest":
rsync -av host: /dest
rsync -av host::module /dest
You can also use rsync in local-only mode, where both the source and destination
don’t have a ’:’ in the name. In this case it behaves like an improved copy com‐
mand.
Я часто использую следующую командную строку, чтобы проверить, что произойдет, «сухой запуск»,
sudo rsync -Havn source-dir/ target-dir
и следующую командную строку для выполните задание,
sudo rsync -Hav source-dir/ target-dir
Редактирование:
Я использую sudo при локальном запуске, чтобы иметь возможность сохранять права собственности и разрешения, что очень важно для системных файлов и файлы конфигурации. Если вы хотите сделать то же самое, используйте Linux-файловую систему, например ext4 на внешнем диске.
Если вы только «копируете файлы данных (документы, изображения, мультимедийные файлы ... ) вам не нужно беспокоиться о разрешениях и использовать более простую командную строку rsync
Изменить:
Обратите внимание на конечную косую черту. См.
man rsync
для получения подробной информации о концевой косой черте и параметрах (-H, -a, -v, -n и -t)
You use rsync in the same way you use rcp. You must specify a source and a des‐
tination, one of which may be remote.
Perhaps the best way to explain the syntax is with some examples:
rsync -t *.c foo:src/
This would transfer all files matching the pattern *.c from the current direc‐
tory to the directory src on the machine foo. If any of the files already exist
on the remote system then the rsync remote-update protocol is used to update the
file by sending only the differences in the data. Note that the expansion of
wildcards on the commandline (*.c) into a list of files is handled by the shell
before it runs rsync and not by rsync itself (exactly the same as all other
posix-style programs).
rsync -avz foo:src/bar /data/tmp
This would recursively transfer all files from the directory src/bar on the
machine foo into the /data/tmp/bar directory on the local machine. The files are
transferred in "archive" mode, which ensures that symbolic links, devices,
attributes, permissions, ownerships, etc. are preserved in the transfer. Addi‐
tionally, compression will be used to reduce the size of data portions of the
transfer.
rsync -avz foo:src/bar/ /data/tmp
A trailing slash on the source changes this behavior to avoid creating an addi‐
tional directory level at the destination. You can think of a trailing / on a
source as meaning "copy the contents of this directory" as opposed to "copy the
directory by name", but in both cases the attributes of the containing directory
are transferred to the containing directory on the destination. In other words,
each of the following commands copies the files in the same way, including their
setting of the attributes of /dest/foo:
rsync -av /src/foo /dest
rsync -av /src/foo/ /dest/foo
Note also that host and module references don’t require a trailing slash to copy
the contents of the default directory. For example, both of these copy the
remote directory’s contents into "/dest":
rsync -av host: /dest
rsync -av host::module /dest
You can also use rsync in local-only mode, where both the source and destination
don’t have a ’:’ in the name. In this case it behaves like an improved copy com‐
mand.