Automatically backs up data to the server and deletes the backup _win server before the specified number of days through FTP under Windows

Source: Internet
Author: User

Description

1, to back up the file in the D-packing directory, named after the time (generally we through the security of God's good backup software to achieve backup) for example
D:\data_db_201112130001.BAK
D:\data_db_201112140002.BAK
D:\data_db_201112150003.BAK
A new file is automatically generated every day, such as December 16, 2011, which automatically generates Data_db_201112160004.bak


2, to the d:\ of the following day to generate the data back to the FTP server, for example, today is December 16, 2011, to data_db_201112160004.bak this file uploaded to the FTP server, and delete data from 7 days ago (only the last 7 days of backup)
FTP server: 192.168.1.1
Port: 21
User name: admin
Password: 123456
Backup file directory Databak


Save the following code to ask Data.bat, and add it to the scheduled task of Windows to automatically execute it every day.

Copy Code code as follows:

@echo off
Echo.
Set data=%date:~0,4%%date:~5,2%%date:~8,2%
set/a deldata=data-7
Echo Open 192.168.1.1 >ftp.txt
Echo Admin>>ftp.txt
Echo 123456>>ftp.txt
Echo Binary>>ftp.txt
echo CD Databak>>ftp.txt
echo LCD D:\>>ftp.txt
Echo Prompt>>ftp.txt
Echo Mput data_db_%data%*. BAK >>ftp.txt
Echo Mdelete data_db_%deldata%*. BAK >>ftp.txt
Echo Close>>ftp.txt
Echo Bye>>ftp.txt
Ftp.exe-s:ftp.txt
Echo.


For better stability, I generally use rsync to achieve backup, more convenient. The above software everyone to cloud Habitat Community Server commonly used software columns to download.

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.