using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.SqlServer.Management.Smo;

namespace Back
{
    class Program
    {
        static void Main(string[] args)
        {
            Server s = new Server();

            Backup b = new Backup();
            b.Database = "pubs";
            b.Devices.AddDevice(@"C:\backups\pubs.bak", DeviceType.File); 
            b.Action = BackupActionType.Database;
            b.SqlBackup(s);

            Restore r = new Restore();
            r.Devices.AddDevice(@"C:\backups\pubs.bak", DeviceType.File);
            r.Action = RestoreActionType.Database;
            r.Database = "pubs";
            r.ReplaceDatabase = true;
            r.SqlRestore(s);
        }
    }
}
