Auto FTP
Auto FTP
WWW Server Web Pages Backup Server 1. WWW Server (a) .netrc
machine 120.107.152.4 login backup password **********
(b) .netrc
$ chmod 600 .netrc
(c) Backup Sever (120.107.152.4) backup account .netrc (d) shell script FTP
#!/bin/bash # ftp1 cd /home/tkwu/www tar zcf ../www-`date +%d`.tar.gz * ftp -i << backup open 120.107.152.4 bin lcd /home/tkwu/www cd /home/backup put www-`date +%d`.tar.gz quit backup
(e) (d) shell script auto_ftp 700 (f) crontab $ crontab e 0 4 * * 0 auto_ftp
<<Basic FTP Commands>> ? ascii to request help or information about the FTP commands to set the mode of file transfer to ASCII (this is the default and transmits seven bits per character)
to set the mode of file transfer to binary (the binary mode transmits all eight bits per byte and thus binary provides less chance of a transmission error and must be used to transmit files other than ASCII files) bye cd close delete get help lcd ls to exit the FTP environment (same as quit) to change directory on the remote machine to terminate a connection with another computer to delete (remove) a file in the current remote directory (same as rm in UNIX) to copy one file from the remote machine to the local machine to request a list of all available FTP commands to change directory on your local machine (same as UNIX cd) to list the names of the files in the current remote directory to copy multiple files from the remote machine to the local machine; you are prompted for a y/n answer before transferring each file
mkdir to make a new directory within the current remote directory mget
to copy multiple files from the local machine to the remote mput machine; you are prompted for a y/n answer before transferring each file open put pwd quit rmdir to open a connection with another computer to copy one file from the local machine to the remote machine to find out the pathname of the current directory on the remote machine to exit the FTP environment (same as bye) to to remove (delete) a directory in the current remote directory