Linux FTP Remote backup shell script command

Source: Internet
Author: User
Tags ftp login

Regularly back up each server's shake data, to the FTP server, pay attention to the active mode and the passive mode difference

#!/bin/bash# active FTP is beneficial to server, client iptables shutdown, client needs to execute Passsiveh after uploading data # Passive FTP is beneficial to client, server side iptables off, Linux Client FTP login does not need to execute the passive command, can upload # #vim  /etc/sysconfig/iptables# Open Firewall port active mode, the client firewall needs to shut down #-a input  -p tcp --dport 20 -j accept#-a input -p tcp --dport 21  -j acceptyum install vsftpdvsftprun () {chkconfig vsftpd onservice vsftpd  startchkconfig iptables off}vsftprunvim /etc/vsftpd/vsftpd.conf# Add anonymous user upload permissions #anonymous_enable=yes #anon_upload_enable =yes#anon_mkdir_write_enable=yes#anon_root=/var/ftproot#anon_umask=022#anon_other_write_ Enable=yeslocal_enable=yeswrite_enable=yeslocal_umask=022dirmessage_enable=yesxferlog_enable=yesconnect_from_ Port_20=yesxferlog_std_format=yeslisten=yespam_service_name=vsftpduserlist_enable=yestcp_wrappers=yesmkdir  -p /var/ftproot/{upload,download}chmod 777 /var/ftproot/uploadvsftprun# Client Configuration yum  INSTALL&NBSP;-Y&NBSP;FTP#FTP Remote backup file #!/bin/bashhost= "172.16.16.23" id= "Zhang" pw= "password" basedir= "/etc" ip_addr= ' ifconfig | grep   ' inet  Addr: '  | grep -v  ' 127.0.0.1 '  | cut -d: -f 2 | awk  ' {print $1} ' current_date= ' date +%y-%m-%d ' remotedir= "/var/ftproot/upload" backupfile= "' date +%Y- %m-%d '. etc.tar.gz "cd /tmptar -zcvf " $ip _addr "-" $backupfile "  $basedirif  [ $?  -eq 0 ]; thenftp -n  "$host"  >/tmp/$ip _addr-etc-$current _date.log 2 >&1 <<EOFuser zhang passwordbinarycd  "$remotedir" put  "$ip _addr"-"$ Backupfile "put " $ip _addr "-etc-" $current _date ".logbyeeofelse         echo  "Tar false" fi


You can also turn on uploading files using anonymous logins


This article is from the "Potato It" blog, be sure to keep this source http://malin314.blog.51cto.com/7206614/1865848

Linux FTP Remote backup shell script command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.