wget http://www.example.com/min.php?page=home&user=ma
wget-r http://www.example.com/
wget-c http://www.example.com/xyz.html
wget-A.jpg http://www.example.com/
wget – limit-rate = 30k http://www.example.com/
wget-r l4 ftp://username:password @ example.com /
wget -i ~/bin/data/getme
Copy the file "foobar.txt" from the local host to a remote host
Copy the directory "foo" from the local host to a remote host's directory "bar"
Copy the file "foobar.txt" from remote host "rh1.edu" to remote host "rh2.edu"
your_username@rh2.edu:/some/remote/directory/
Copying the files "foo.txt" and "bar.txt" from the local host to your home directory on the remote host
Copy multiple files from the remote host to your current directory on the local host
$ rsync options source destination
Synchronize Two Directories in a Local Server
$ rsync -zvr /var/dir1/ /root/dir2
-z :enable compression
-v :verbose
Preserve timestamps during Sync using rsync -a
rsync -azv /var/dir1/ /root/dir2
rsync -arzv /var/dir1/ /root/dir2 (this will do recursively)
a = archive - means it preserves permissions (owners, groups), times, symbolic links, and devices. r = recursive - means it copies directories and sub directories v = verbose - means that it prints on the screen what is being copied
Synchronize Only One File
rsync -v /var/singlefile /root/myfile/
Synchronize only the Directory Tree Structure (not the files)
rsync -v -d abc@192.168.200.10:/var/lib/ .
When using "/" at the end of source, rsync will copy the content of the last folder.
When not using "/" at the end of source, rsync will copy the last folder and the content of the folder.
When using "/" at the end of destination, rsync will paste the data inside the last folder.
When not using "/" at the end of destination, rsync will create a folder with the last destination folder name and paste the data inside that folder.
rsync -avz /myDir user@remotemachine:/backups/
The following example will make an incremental backup of the directory /data/working/ and put a copy of any file that changes into a dated directory in /BACKUP/ . This can be used to keep a daily backup tree of any changed files and not have to overwrite the previous days files. Note that this method does need to copy the entire file if it changes as the new files are made in the directory named under current day.
rsync --backup --backup-dir=`date +%Y.%m.%d` -a /data/working/ /BACKUP/
LFTP
#!/bin/bash HOST="your.ftp.host.dom"USER="username" PASS="password"LCD="/path/of/your/local/dir"RCD="/path/of/your/remote/dir" lftp -c "set ftp:list-options -a;open ftp://$USER:$PASS@$HOST;lcd $LCD;cd $RCD; mirror --reverse \ --delete \ --verbose \ --exclude-glob a-dir-to-exclude/ \ --exclude-glob a-file-to-exclude \ --exclude-glob a-file-group-to-exclude* \ --exclude-glob other-files-to-exclude"
lftp -e 'put /local/path/yourfile.txt; bye' -u user,password ftp.remote.com
lftp -e 'set net:timeout 10; get yourfile.txt; bye' -u user,password ftp.remote.com
mirror command, LFTP is recursive by default./local/path to the root of the remote FTP site,
including all subdirectories and their files. The -R switch means “reverse
mirror” which means “put” [upload]. Remote path is simply /, the root.lftp -e 'mirror -R /local/path/ /' -u user,password ftp.remote.com
Recursive Download
-R param and swap remote
path with local. Be careful with this. Don’t overwrite your local changes.lftp -e 'mirror / /local/path/' -u user,password ftp.remote.com
Special Characters in Username or Password
Special characters in your username or password must be escaped with backslashes:lftp -e 'put /pathToyourfile.txt; bye' -u user,password\!\! ftp.remote.com