Web design and hosting, database, cloud and social media solutions that deliver business results
  • ビジネスソリューション
    • データベースサービス
      • サーバーのアップグレードと DBA サービス
      • データウェアハウス サービス
      • データ統合
      • パワーBI
    • ウェブサイトデザイン
      • Web サイトのセキュリティ
      • Web サイトの最適化
      • ロゴデザイン
      • 支払いゲートウェイ
      • テクニカルツール
    • ビジネスサービス
      • Google クラウド サービス
      • アマゾン ウェブ サービス
      • マイクロソフト アズール
    • ソーシャルメディア
    • マイクロソフトオフィス
  • 学校
    • テスト環境
    • 学習データベース
      • 基礎
      • SQL Serverデータ
      • SQLServerのメンテナンス
      • SQL Serverの日付の使用
      • SQLServerピボットの使用-ピボット解除
      • SQLServer関数の使用
      • オープンクエリを取得
      • ツール
    • ウェブデザインを学ぶ
      • Ousia コンテンツ管理システムの構築
      • ASP-NET の使用
      • CSS の使用
      • JavaScript の使用
    • クラウドと IT サービスの学習
      • タスク スケジューラ エラー 2147943645
      • OpenSSL での SSL の要求と PFX ファイルの生成の簡単な手順
    • ソーシャル メディアの使用
      • Facebookアカウントを個人用からビジネス用に変更する
      • Google レビューを依頼する
      • ソーシャル メディアの取り組みをどこに集中させるかを選択する
      • ソーシャル メディアの画像サイズ
      • メタ データを使用してソーシャル メディア画像を設定する
  • 私たちに関しては
    • ブログ
      • Google コア アップデート 2020 年 1 月
      • インターネット上のウェブサイトに関する最も厄介なこと
      • ウェブサイトの広告リーフレットのコンテンツを選択する方法
      • エントリーレベルのゲーム機の構築
      • オンライン詐欺の防止
      • ギグエコノミーのスキマー
      • ホットチリインターネット閉鎖
      • 無料のベクター グラフィックスのトップ 5 Web サイト
    • キャリア
      • 翻訳者 英日
      • 英語-トルコ語翻訳者
    • チーム
      • アイセ・ハー
      • アリ アル アミン
      • ギャビン・クレイトン
      • サイガングー
      • スーリヤ・ムッカマラ
      • スニール・クマール
      • チェスターコッパーポット
    • ポートフォリオ
English (EN-GB)English (EN-US)Español (ES)हिंदी (HI)italiano (IT)日本語 (JA)Türk (TR)

SQL Server 2008 7Zip データベース バックアップ

xp_cmdshell を有効にしてから、7Zip コマンド ラインからデータベース バックアップ バックアップを実行する SQL コード。

Context

I recently came across the need to FTP copy database backups off site, while you can obviously do this with standard backup files, large files would take quite some time, so we looked at 7 zip as a tool to further compress the data, as the database is always on-line, and the built in compression takes quite a hit on performance.

7 zip would be run via the xp_cmdshell utility which is disabled by default. to set it up, use the following commands via sp_configure. This snippet was taken from the Microsoft site.

SQL

-- To allow advanced options to be changed.EXEC sp_configure 'show advanced options', 1;GO-- To update the currently configured value for advanced options.RECONFIGURE;GO-- To enable the feature.EXEC sp_configure 'xp_cmdshell', 1;GO-- To update the currently configured value for this feature.RECONFIGURE;
Now that we have turned that on, we can now set up the following stored procedure, this code could be utilised as part the complete maintenance plan (backup, restore and re-index).

SQL

CREATE PROC dbo.DatabaseBackup(@Database NVARCHAR(100),@Folder NVARCHAR(100),@DatabaseRAR BIT)AS BEGINIF RIGHT(@Folder,1)<>'\' SET @Folder=@Folder+'\'DECLARE @Source VARCHAR(1000)=@Folder+@Database+'.bak'DECLARE @Destin VARCHAR(1000)=@Folder+@Database+'.rar'DECLARE @Command VARCHAR(1000),@CommandDel VARCHAR(1000)
DECLARE @BackupScript NVARCHAR(1000)='BACKUP DATABASE '+@Database+' TO DISK=N'''+@Source+'''WITH NOFORMAT, INIT, NAME =N'''+@Database+'_Backup'', SKIP, NOREWIND, NOUNLOAD, STATS= 10;'EXEC (@BackupScript)
IF @DatabaseRAR=1 BEGIN  SET @CommandDel = N'del '+@Destin+''  SET @Command = N'"C:\Program Files\7-Zip\7z.exe" a '+@Destin+' '+@Source+' '  PRINT @Command  EXEC xp_cmdshell @CommandDel  EXEC xp_cmdshell @CommandENDENDGOEXEC DatabaseBackup 'db','C:\\',1

When set up, a 20GB database backup took 7 minutes, and then to zip it took just over an hour. If possible, you would want this done on a separate server or at separate drives away from your databases to avoid Disk IO contention.

Database Backup Sizes

Here is a screenshot of the backup compression rates on a database, where you can see the .rar file is about a third the size of the compressed backup, and the compressed backup is just over half the size of the uncompressed one.

The FTP is done separately at present, but in due course I will be building in the FTP to this code...

Author

Was this helpful?

Please note, this commenting system is still in final testing.
Copyright Claytabase Ltd 2020

Registered in England and Wales 08985867

RSSLoginLink クッキーポリシーサイトマップ

Social Media

facebook.com/Claytabaseinstagram.com/claytabase/twitter.com/Claytabaselinkedin.com/company/claytabase-ltd

Get in Touch

+442392064871info@claytabase.comClaytabase Ltd, Unit 3d, Rink Road Industrial Estate, PO33 2LT, United Kingdom
The settings on this site are set to allow all cookies. These can be changed on our Cookie Policy & Settings page.
By continuing to use this site you agree to the use of cookies.
Ousia Logo
Logout
Ousia CMS Loader