This shows you the differences between two versions of the page.
Previous revision | |||
linux:scripts:ftpsync [2017/10/02 15:11] – Discussion status changed lunetikk | — | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== FTP sync (download) ===== | ||
- | This script can be used to download all files from a dir on your ftp to a dir on your local harddrive. They will be synchronized and if everything is correctly downloaded they will be removed from ftp. A logfile will be written. | ||
- | |||
- | <code - ftprsync.sh> | ||
- | #!/bin/bash | ||
- | |||
- | # | ||
- | while true | ||
- | do | ||
- | |||
- | #var Hostname | ||
- | HOST=' | ||
- | |||
- | #var Username | ||
- | USER=' | ||
- | |||
- | #Path to FTPLogfile | ||
- | LOGPATH=/ | ||
- | |||
- | #Path to FTP data | ||
- | FTPPATH=/ | ||
- | |||
- | #Path to local directory | ||
- | PATH=/ | ||
- | |||
- | #check if there are textfiles to sync | ||
- | if ssh $USER@$HOST "ls $FTPPFAD*.txt" | ||
- | then | ||
- | |||
- | #if there are textfiles sync them to the localdir and remove them from FTP | ||
- | #log number of files, speed, which files... to the logfile. -q (quiet) only shows error in shell nothing else | ||
- | rsync --remove-source-files --stats --progress --log-file=$LOGPATH -q ${USER}@${HOST}: | ||
- | fi | ||
- | |||
- | #short wait time -> less cpu usage | ||
- | sleep 5 | ||
- | done | ||
- | </ | ||
- | \\ | ||
- | \\ | ||
- | ~~DISCUSSION: |