Remote Backup after application deployment

Source: Internet
Author: User

After application deployment, users start to input data, worry about the application is not stable, so every day after the user input data, to back up the application system;
Due to the design time, some files stored in the database are stored in the file path, so after the database is backed up,
The files corresponding to the path need to be backed up synchronously. So that it can be fully recovered when recovering.

REM------------------------------------------------------------------------
REM The following is the backup batch file contents
REM------------------------------------------------------------------------
E:
CD E:\prodname_backup

Set fn_date=%date:~0,4%%date:~5,2%%date:~8,2%
If "%time:~0,1%" = "" "(set fn_time=0%time:~1,1%%time:~3,2%%time:~6,2%) Else (set Fn_time=%time:~0,2%%time:~3,2%%time: ~6,2%)
Set fld=%fn_date%_%fn_time%
Set Fn=prodname_%fn_date%_%fn_time%.backup
mkdir%fld%

C:
CD C:\Program Files (x86) \pgadmin iii\1.20\

The Echo 1 backup begins ...... .....
Pg_dump.exe--host 192.168.0.105--port 5432--username "Pgsql"--role "Pgsql"--no-password--format custom--blobs--sec tion pre-data--section data--section post-data--encoding UTF8--inserts--column-inserts--verbose--file "e:\prodname_ backup\%fld%\%fn% "" Proddbname "
Echo 1 backup is over ...... .....

Echo 2 Create a local database with the same name to start with ....
Psql--host 127.0.0.1--dbname=postgres--username=pgsql-f e:\prodname_backup\drop_create_localdb.sql
Echo 2 creates a local database with the same name ......

Echo 3 reverts to the local database with the same name ......
Pg_restore.exe--host localhost--port 5432--username "Pgsql"--dbname "Proddbname"--role "Pgsql"--no-password--sectio n pre-data--section data--section post-data--verbose "e:\prodname_backup\%fld%\%fn%"
Echo 3 reverts to the end of the local database with the same name .....


Winscp.exe/console/command "option Batch Continue" "option confirm off" "Open Sftp://username:[email protected]:22" "opt Ion transfer binary "" Get/home/username/projdir e:\prodname_backup\%fld%\projdir "Exit"/log=e:\prodname_backup\% Fld%\winscp-log.txt

E:
CD e:\prodname_backup\%fld%
Dir%fn%
Cd..


------------------------------------------------------------------------
SQL content, database is rebuilt every time, if not rebuilt, recovery is always reported permissions issues
------------------------------------------------------------------------
Drop database if exists proddbname;
Create DATABASE Proddbname


The only thing worth recording is the SCP;
First try to install Cygwin, download OpenSSH, and then use its with the SCP;
SCP cannot make a password directly on the command line by using the key,
A secret key was generated with Ssh-keygen on the server and copied to the Cygdrive/c/home/username/.ssh.
Useless, do not know the Cygwin in the SCP key how to specify, only two Linux systems can be successful
Wasted a lot of time, repeated trials, not all;
Use WINSCP,WINSCP direct to specify user name and password, easy to take care of;

Remote Backup after application deployment

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.