Exemplo n.º 1
0
        private void SilenceBackup(object source, ElapsedEventArgs e)
        {
            List <string> credentials    = UtilVarios.GetCredentialsDB();
            string        server         = credentials[0];
            string        user           = credentials[1];
            string        database       = credentials[2];
            string        pass           = credentials[3];
            DataTable     tbl            = BL.GetDataBLL.RazonSocial();
            string        fileSilenceBck = @"c:\windows\temp\" + tbl.Rows[0][0].ToString() + "_bck.sql";
            string        remoteFile     = tbl.Rows[0][0].ToString() + "_bck.sql.xz";

            UtilDB.DumpDB(server, 3306, user, pass, database, fileSilenceBck);
            if (File.Exists(fileSilenceBck + ".xz"))
            {
                File.Delete(fileSilenceBck + ".xz");
            }
            UtilDB.ZipDB(fileSilenceBck);
            MemoryStream ms = new MemoryStream();

            using (FileStream fs = File.OpenRead(fileSilenceBck + ".xz"))
            {
                fs.CopyTo(ms);
            }
            try
            {
                BL.UtilFTP.UploadFromMemoryStream(ms, remoteFile, "trendsistemas");
            }
            catch (WebException)
            {
                return;
            }
        }
Exemplo n.º 2
0
        private void backup_Click(object sender, EventArgs e)
        {
            SaveFileDialog fichero = new SaveFileDialog();

            fichero.Filter   = "SQL (*.sql)|*.sql";
            fichero.FileName = "Backup";
            if (fichero.ShowDialog() == DialogResult.OK)
            {
                List <string> credentials = UtilVarios.GetCredentialsDB();
                string        server      = credentials[0];
                string        user        = credentials[1];
                string        database    = credentials[2];
                string        pass        = credentials[3];
                UtilDB.DumpDB(server, 3306, user, pass, database, fichero.FileName);
            }
        }