ftpsync
This is an old revision of the document!
#!/bin/bash
#
# Synchronise deux répertoires en utilisant FTP
HOST="myserver.com"
LOGIN="mylogin"
PASSWORD="mypass"
LOCALDIR="$1"
REMOTEDIR="$2"
EXCLUDED="*.*~"
function Usage()
{
echo -e "\n Synchronise un répertoire local avec un répertoire distant en utilisant FTP";
echo -e "\n USAGE: ftpsync local_dir";
echo;
}
if [ "$LOCALDIR" = "" ]
then
echo -e " ERREUR: Veuillez spécifier un répertoire local";
Usage;
exit 1;
fi
if [ "$REMOTEDIR" = "" ]
then
echo -e " ERREUR: Veuillez spécifier un répertoire distant";
Usage;
exit 1;
fi
if [ -e "$LOCALDIR" ]
then
lftp -c "set ftp:list-options -a;
open ftp://$LOGIN:$PASSWORD@$HOST;
lcd $LOCALDIR;
cd $REMOTEDIR;
mirror --reverse \
--delete \
--verbose \
--exclude-glob $EXCLUDED";
fi
check if folder/file exists
#!/bin/bash wget --tries=1 --spider -S ftp://myserver.com/test 2>&1 | grep "No such file" > /dev/null && echo "not exist" || echo "exist" wget --tries=1 --spider -S ftp://myserver.com/testa 2>&1 | grep "No such file" > /dev/null && echo "not exist" || echo "exist"
ftpsync.1485863370.txt.gz · Last modified: (external edit)
