Synchronize data to FTP with WinSCP

Synchronize data to FTP with WinSCP

I recently discovered WinSCP, a Free SFTP, FTP and SCP client for Windows. It has a graphical interface, but for me the most important feature is that you can easily script your way to a very fast and automated synchronization system with the software.

WinSCP

First download and install the WinSCP software.

Then, create a txt file somewhere on your computer and use a similar script:
# Automatically answer all prompts negatively not to stall the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
open ftp://user:password@IPaddress
# Change remote directory
cd /myDestinationFolder/myDestinationSubFolder
# Force binary mode transfer
option transfer binary
synchronize remote C:mySourceFoldermySourceSubFolder
# Disconnect
close
# Exit WinSCP
Exit

Then create a bat file in the same directory:
@ECHO off
cd “C:Program FilesWinSCP”
winscp.exe /console /script=C:PathToTxtFileJustCreatedTxtFileJustCreated.txt /log=”C:LogPathwinscp.log”

Then you can use TaskScheduler to schedule the bat file and your synchronization process is complete!

Full and differential backups in SQL

Full and differential backups in SQL

To set up backups automatically, use these scripts in combination with SQL Agent. In general, you make a full backup once a week and the rest of the week differential backups. Each differential backup holds the data between the time the differential backup was taken and the time that the last full backup was taken.

Full and differential backup in SQL

– Full backup

DECLARE @filename AS VARCHAR(255)
DECLARE @backupSetId AS INT

SET @filename = N‘C:DBBackupDailyBackupDBName_‘ + CAST(YEAR(GETDATE()) AS VARCHAR(4)) + CAST(MONTH(GETDATE()) AS VARCHAR(2)) + CAST(DAY(GETDATE()) AS VARCHAR(2)) + N’.bak’
BACKUP DATABASE [DBName] TO  DISK = @filename WITH NOFORMAT, INIT,  NAME = N’DBName-Full Database Backup’, SKIP, NOREWIND, NOUNLOAD,  STATS = 10
select @backupSetId = position from msdb..backupset where database_name=N’DBName’ and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N’DBName’ )
if @backupSetId is null begin raiserror(N’Verify failed. Backup information for database ”DBName” not found.’, 16, 1) end
RESTORE VERIFYONLY FROM  DISK = @filename WITH  FILE = @backupSetId,  NOUNLOAD,  NOREWIND

 

– Differential backup

DECLARE @filename AS VARCHAR(255)
DECLARE @backupSetId AS INT

SET @filename = N’C:DBBackupDailyBackupDBName_Diff_’ + CAST(YEAR(GETDATE()) AS VARCHAR(4)) + CAST(MONTH(GETDATE()) AS VARCHAR(2)) + CAST(DAY(GETDATE()) AS VARCHAR(2)) + N’.bak’
BACKUP DATABASE [DBName] TO  DISK = @filename WITH  DIFFERENTIAL , NOFORMAT, INIT,  NAME = N’DBName-Differential Database Backup’, SKIP, NOREWIND, NOUNLOAD,  STATS = 10
select @backupSetId = position from msdb..backupset where database_name=N’DBName’ and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N’DBName’ )
if @backupSetId is null begin raiserror(N’Verify failed. Backup information for database ”DBName” not found.’, 16, 1) end
RESTORE VERIFYONLY FROM  DISK = @filename WITH  FILE = @backupSetId,  NOUNLOAD,  NOREWIND

 

Note: You can’t make a differential backup before having first created a full backup.
Note 2: Change DBName in the code above in the name of your own database!
Note 3: If you copy/paste this code in SQL Server, please remove the single quotes and type them again. For some reason, my blog makes them into foreign characters for SQL Server.

Dropbox: free online backup and file sharing tool

A while ago I came across a free online backup and file sharing tool, called Dropbox.

Dropbox

Dropbox is available for every OS out there: OS X, Windows, Iphone, Blackberry, Android, … and they have an online interface. When you install their software on your device of choice, it creates a simple folder which you can use like any other folder on your device, with the benefit that it automatically syncs with the data online and any other device on which the software is installed. When you add/remove or alter any content, it will automatically update the content online and on other devices too. This way, you always have the same, up-to-date data anywhere you need it.

Not only can you keep your own documents in sync and have an automatic backup of your data, you can also create a shared folder where you can drop files that you want others to be able to access.

With its 2GB you get a decent amount of online space where you can work with. You can increase this volume by taking their tour, adding a second computer, inviting other people, … or of course, by buying more space.

Download dropbox here and give it a try. I’m sure you’ll love it!