toxerli
toxerli

Reputation: 17

How to delete all files with lftp except for cgi-bin and .ftpquota

I'm setting up a new ci/cd pipeline on gitlab. For the deployment I have to run npm run build and then copy the dist/ folder to the webserver via ftp (with lftp). To ensure a clean deployment the script should remove all files except the folder cgi-bin and the file .ftpquota on the webserver first and then copy the files.

I've researched through the web and haven't found a suitable solution. With the flag --delete, lftp deletes all files.

Thats my script so far:

- lftp -c "set ftp:ssl-allow no; open -u $USERNAME,$PASSWORD $HOST; mirror -Rnev dist/ ./ --ignore-time --delete --parallel=10 --exclude-glob .git* --exclude .git/"

My current script removes all files, but I want it to remove everything except the cgi-bin folder and the .ftpquota file.

Upvotes: 1

Views: 1616

Answers (1)

As seen in unix.stackexchange.com you should add the -x option:

Please check it

Upvotes: 1

Related Questions