简体   繁体   中英

sftp upload bash ignore files

I try to achieve some semi-automatic sftp upload/deployment. The main key is NOT to upload all files. I do not know which files to upload but I know which files not to upload.

My bash script looks like:

#!/bin/bash

IP="123.123.123.123"
HOSTNAME="ftp.my-host.com"
PATH="subdirectory"

sftp username@$HOSTNAME:$PATH < "sftp-pattern"

in the sftp-pattern file i want to store my sftp commands. But I could not find any hints how to ignore several patterns. like *.sql .

Ideally i'd ignore everything that is gitignored.

I do NOT have an ssh connection.

Since you are using a shell script, you could use a loop. Something like this should work.

#!/bin/bash

IP="123.123.123.123"
HOST="ftp.my-host.com"
DIR="/tmp/"

for f in `/bin/ls $DIR`
do
  if echo $f | /usr/bin/grep  '.sql' > /dev/null
  then
    echo SKIPPING $f
  else
   sftp username@$HOST:$DIR/$f
  fi
done

The answer should be git-ftp as @Clijsters mentioned. It is more feature rich and needs no fiddeling around with loops and pipes.

dwrights solution is working though, if it is ONLY sql that you want to exclude.

Thanks!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM