Приходится использовать FTP и хорошо, что есть один замечательный клиент - lftp.
Ставим lftp:
cd /usr/ports/ftp/lftp/
make install clean
А теперь делаем маленький скриптик:
cat ./ftp_sync
#!/bin/sh
lftp -p 21 -u user,pAssW0rD ftp.server/remote/dir << cmd
mirror -R -c -v --log=/var/log/lftp.log /local/dir .
quit
листинг всех параметров lftp mirror:
Usage: mirror [OPTS] [remote [local]]
Mirror specified remote directory to local directory
-c, --continue continue a mirror job if possible
-e, --delete delete files not present at remote site
--delete-first delete old files before transferring new ones
-s, --allow-suid set suid/sgid bits according to remote site
--allow-chown try to set owner and group on files
--ignore-time ignore time when deciding whether to download
-n, --only-newer download only newer files (-c won't work)
-r, --no-recursion don't go to subdirectories
-p, --no-perms don't set file permissions
--no-umask don't apply umask to file modes
-R, --reverse reverse mirror (put files)
-L, --dereference download symbolic links as files
-N, --newer-than=SPEC download only files newer than specified time
-P, --parallel[=N] download N files in parallel
-i RX, --include RX include matching files
-x RX, --exclude RX exclude matching files
RX is extended regular expression
-v, --verbose[=N] verbose operation
--log=FILE write lftp commands being executed to FILE
--script=FILE write lftp commands to FILE, but don't execute them
--just-print, --dry-run same as --script=-
Таким образом, на удалённый ftp из локальной директории загружаются новые и измененные файлы. Если нужно удалять отсутствующие файлы в локальной директории необходим параметр -e, а исключить не нужные файлы/директории --exclude name
Комментариев нет:
Отправить комментарий