Jump to content

Programa gratuito Backup


JoseDroid

Recommended Posts

  • 1 year later...

Boa tarde, Você pode estar fazendo um script de backup , você pode estar comprando um espaço na nuvem se subindo , tipo você pode estar fazendo um programinha que funciona invisível, e com uma hora determinada ele faz o backup e sobe para nuvem, vou colocar aqui uns tutoriais que vai te ajudar 

cria uma pasta e deixa esse arquivo .bat lá , quando chegar uma determinada hora ele executa depois que gerar o  .log o programinha pega o .backup e leva na nuvem

@echo off CLS echo Running dump ... sqlcmd -S SERVER\SQLEXPRESS -U username -P password -Q "BACKUP DATABASE master TO DISK='D:\DailyDBBackup\DB_master_%date:~-10,2%%date:~-7,2%%date:~-4,4%.bak'" echo Zipping ... "C:\Program Files\7-Zip\7z.exe" a -tzip "D:\DailyDBBackup\DB_master_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%.bak.zip" "D:\DailyDBBackup\DB_master_%date:~-10,2%%date:~-7,2%%date:~-4,4%.bak" echo Deleting the SQL file ... del "D:\DailyDBBackup\DB_master_%date:~-10,2%%date:~-7,2%%date:~-4,4%.bak" echo Done!
public static void EnviarArquivoFTP(string arquivo, string url, string usuario, string senha) { try { FileInfo arquivoInfo = new FileInfo(arquivo);

FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri(url));

request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(usuario, senha); request.UseBinary = true; request.ContentLength = arquivoInfo.Length;

using (FileStream fs = arquivoInfo.OpenRead()) { byte[] buffer = new byte[2048]; int bytesSent = 0; int bytes = 0;

using (Stream stream = request.GetRequestStream()) { while (bytesSent < arquivoInfo.Length) { bytes = fs.Read(buffer, 0, buffer.Length); stream.Write(buffer, 0, bytes); bytesSent += bytes; } } } } catch (Exception ex) { throw ex; } }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.