Backup zip and transfer to FTP Backup Server an SQL-Server Express Database every hour -


i need backup sql-server express database, zip , transfer ftp server every hour.

so far i'm able create backup, i'm not able zip (i tried 7z) , transfer command line:

the script.sql file:

declare @pathname nvarchar(512)  set @pathname = 'c:\prd-db-backup-' + replace(replace(replace(convert(varchar(19), getdate(), 126),'-',''),'t',''),':','') + '.bak'  backup database [database]  disk = @pathname noformat, noinit,  name = n'database-full database backup', skip, norewind, nounload,  stats = 10 

the bat file:

sqlcmd -s sqlserver -u user -p password -i script.sql problem1: 7z -tzip c:\prd-db-backup-%date%%time%.zip -i! c:\prd-db-backup-%date%%time%*.bak ftp transfer: ? 

thanks.

depending on locale setting might have adjust date/time parsing

rem last 10 chars  in either dd-mm-yyyy or mm-dd-yyyy  set dtm=%date:~-10%  rem last 4 year set yyyy=%dtm:~-4%   set mm=%dtm:~4,2% set dd=%dtm:~1,2%  set tim1=%time:.=% set tim2=%tim1:,=% rem lets copy everyting date sqlcmd -s sqlserver -u user -p password -i script.sql  7z -tzip c:\prd-db-backup-%yyyy%%mm%%dd%%tim2%.zip -i! c:\prd-db-backup-%yyyy%%mm%%dd%*.bak  echo user your-ftp-username > ftpcmd.txt echo pwd  your-ftp-password >> ftpcmd.txt echo cd /ftp/dir/to/store >> ftmcmd.txt echo put  c:\prd-db-backup-%yyyy%%mm%%dd%%tim2%.zip >> ftpcmd.txt echo bye >> ftpcmd.txt  ftp -i -s:ftpcmd.txt your-ftp-server 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -