diumenge, 1 de desembre del 2013

FTP Sync with Linux

donat que en un hosting no tinc acces via ssh, i no puc utilitzar rsync per realitzar backups contra ell, utilitzaré la mateixa  estrategia pero ara fent-ho via ftp amb lftp

la meva font d'informació és :

http://www.dangibbs.co.uk/journal/ftp-sync-usin-linux

pero finalment canvio la ordre amb la opció -r per tal de poder pujar del meu servidor al remot, i tot el document està pensat en sentit contrari, del remot a aquest. (jo no puc utilitzar comandes en aquest hosting)

dintre del fitxer lftp-script posaré 
open ftp://username:password@website.com
mirror -R -v --only-newer /var/lib/mysql /eso2/mysql
 
d'aquesta manera envio de sabadell a mirrors hosting en nominalia. 

la web font indica que .....

If you can’t use SSH or have limited access to a server it can be difficult to synchronise or create backups of files such as websites. As asked by Tom here’s how to use the powerful and flexible LFTP to sync a remote FTP account to a local directory using Linux.
First of all you will need to install LFTP via your package manager or from their website at http://lftp.yar.ru/. In Ubuntu, for example, you would use:
1
sudo apt-get install lftp
Next create a small and easy script called lftp-script that LFTP can read:
1
2
open ftp://username:password@website.com
mirror -v --only-newer /home/local/path/ /website.com/public_html/
As lftp-script contains a username and password you will want to remove all group and public permissions on the file with something like;
1
chmod 600 lftp-script
Finally you can run LFTP and start the synchronisation straight away, its that easy and perfect for cron backups:
1
lftp -f /path/to/lftp-script
In the example above I used -v (verbose) and –only-newer so that files that haven’t changed don’t get downloaded and overwritten. There are a ton of arguments that will solve just about every FTP problem needed. Some interesting ones, for mirror, are below.
 mirror [OPTS] [source [target]]
 
       Mirror specified source directory to local target directory. If  target
       directory ends with a slash, the source base name is appended to target
       directory name. Source and/or target can be URLs pointing  to  directo‐
       ries.
 
            -c,    --continue                continue a mirror job if possible
            -e,    --delete                  delete   files   not  present  at
                                             remote site
                   --delete-first            delete old files before transfer‐
                                             ring new ones
                   --depth-first             descend    into    subdirectories
                                             before transferring files
            -s,    --allow-suid              set suid/sgid bits  according  to
                                             remote site
                   --allow-chown             try  to  set  owner  and group on
                                             files
                   --ascii                   use ascii mode transfers (implies
                                             --ignore-size)
                   --ignore-time             ignore time when deciding whether
                                             to download
                   --ignore-size             ignore size when deciding whether
                                             to download
                   --only-missing            download only missing files
                   --only-existing           download   only   files   already
                                             existing at target
            -n,    --only-newer              download  only  newer  files  (-c
                                             won't work)
                   --no-empty-dirs           don't  create  empty  directories
                                             (implies --depth-first)
            -r,    --no-recursion            don't go to subdirectories
                   --no-symlinks             don't create symbolic links
            -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
                   --on-change=CMD           execute  the  command if anything
                                             has been changed
                   --older-than=SPEC         download only  files  older  than
                                             specified time
                   --size-range=RANGE        download  only files with size in
                                             specified range
            -P,    --parallel[=N]            download N files in parallel
                   --use-pget[-n=N]          use pget to transfer every single
                                             file
                   --loop                    loop until no changes found
            -i RX, --include RX              include matching files
            -x RX, --exclude RX              exclude matching files
            -I GP, --include-glob GP         include matching files
            -X GP, --exclude-glob GP         exclude matching files
            -v,    --verbose[=level]         verbose operation
                   --log=FILE                write  lftp  commands  being exe‐
                                             cuted to FILE
                   --script=FILE             write lftp commands to FILE,  but
                                             don't execute them
                   --just-print, --dry-run   same as --script=-
                   --use-cache               use cached directory listings
                   --Remove-source-files     remove  files after transfer (use
                                             with caution)
            -a                               same  as  --allow-chown  --allow-
                                             suid --no-umask
… and for the rest man lftp or take a look at the LFTP online man.

el man es troba a la direcció http://lftp.yar.ru/lftp-man.html