Site Tools


linux:scripts:ftpsync

Differences

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 
- 
-#Endlessloop to sync 
-while true 
-do 
- 
-#var Hostname 
-HOST='localhost' 
- 
-#var Username 
-USER='root' 
- 
-#Path to FTPLogfile 
-LOGPATH=/var/log/ftprsync.log 
- 
-#Path to FTP data 
-FTPPATH=/var/ftp/ 
- 
-#Path to local directory 
-PATH=/var/textfiles/ 
- 
-#check if there are textfiles to sync 
-if ssh $USER@$HOST "ls $FTPPFAD*.txt" >/dev/null 2>&1 
-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}:$FTPPATH*.txt $PATH 
-fi 
- 
-#short wait time -> less cpu usage 
-sleep 5 
-done 
-</code> 
-\\ 
-\\ 
-~~DISCUSSION:closed~~ 
linux/scripts/ftpsync.txt · Last modified: 2017/11/29 16:57 (external edit)