I want to mirror a directory using ftp and want to exclude certain subdirectories (such as logs) and file ending with *.cvs. How do I exclude files while mirroring using lftp command under Linux or Unix like operating systems?
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | lftp ftp client |
Time | N/A |
lftp command exclude syntax
The syntax is as follows:
mirror --exclude RX mirror --exclude-glob GP
In this example exclude logs directory, enter:
mirror --exclude logs/ --exclude
You can use --exclude multiple times:
mirror --exclude logs/ --exclude reports/ --exclude-glob *.bak --exclude-glob *~$
The following will exclude all *.cvs files:
mirror --exclude-glob *.cvs
Putting it all together
Create a file called mirror.http.lftp as follows:
set ftp:list-options -a set cmd:fail-exit true open ftp.cyberciti.biz.biz:/var/www/ lcd /nas06/backup/cyberciti.biz/ mirror --delete --exclude logs/ --exclude tmp/ --exclude-glob *~$ quit
Create or edit an authentication file called ~/.netrc – this file contains configuration and autologin information for the File Transfer Protocol client ftp and lftp:
machine ftp.cyberciti.biz login MyUserNameHer password myPassWordHere
Save and close the file. Run the job as follows:
lftp -f mirror.http.lftp
OR
lftp -f mirror.http.lftp > ~/mirror.http.lftp.log
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |