{"id":163,"date":"2013-01-15T15:13:29","date_gmt":"2013-01-15T15:13:29","guid":{"rendered":"http:\/\/www.nicovs.be\/?p=163"},"modified":"2013-04-02T13:48:07","modified_gmt":"2013-04-02T13:48:07","slug":"using-robocopy-to-copy-backups-and-maintain-file-retention","status":"publish","type":"post","link":"https:\/\/www.nicovs.be\/?p=163","title":{"rendered":"Using Robocopy to copy backups and maintain file retention."},"content":{"rendered":"<p>I am using Tara&#8217;s excellent\u00a0<a title=\"SQL Backup\" href=\"http:\/\/weblogs.sqlteam.com\/tarad\/archive\/2009\/09\/08\/Backup-SQL-Server-2005-and-2008-Databases.aspx\" target=\"_blank\">MsSQL Backup script<\/a>\u00a0to backup my SQL databases. This is an excellent way to backup SQL DB&#8217;s if you have an SQL Express version installed. Heck, \u00a0 I even use this when higher SQL versions are installed (with maintenance plan possibilities and stuff).<br \/>\nOn top of that, I needed a script which was able to:<br \/>\n&#8211; Move my MsSQL BAK files from a local disk to a network path. This is because the backup script does not allow to backup to UNC paths.<br \/>\n&#8211; Clean up older backups on the destination directory.<\/p>\n<p>I found (actually, I already knew) that\u00a0<a title=\"Robocopy Syntax\" href=\"http:\/\/technet.microsoft.com\/en-us\/library\/cc733145(v=ws.10).aspx\" target=\"_blank\">Robocopy<\/a>\u00a0was a very nifty tool to do things like this.<\/p>\n<p>My Howto:<\/p>\n<p>Prepare your destination (backup) drive on your network by creating 2 &#8216;dummy dir&#8217;s:<\/p>\n<ul>\n<li>1 actual backup destination folder on your remote fileserver (eg \\\\bck_svr\\SQL_Backup)<\/li>\n<li>1 directory to move your older files too ( eg \\\\bck_svr\\delete)<\/li>\n<li>1 always directory that acts as a &#8216;delete mirror&#8217;\u00a0( eg \\\\bck_svr\\EMPTY)<\/li>\n<\/ul>\n<p>After that, just download and install the <a title=\"Microsoft Resource Kit Tools\" href=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=17657\" target=\"_blank\">Resource Kit Tools<\/a>, and create a BAT script that looks like:<\/p>\n<pre>c:\r\ncd \"C:\\Program Files (x86)\\Windows Resource Kits\\Tools\"\r\n\r\nREM Move files older than 4 days to a Delete dir, but create them as empty files which fastens everything up (and also directly clears the diskspace :))\r\nrobocopy.exe \\\\bck_svr\\\\SQLBackup \\\\bck_svr\\Delete \/e \/CREATE \/MOVE \/MINAGE:4 \r\n\r\nREM Delete the contents of the 'Delete' dir. \r\nrobocopy.exe \\\\bck_svr\\EMPTY \\\\bck_svr\\Delete \/MIR \/E \r\n\r\nREM Make a new copy of the Dirictoy to backup. \r\nrobocopy \"d:\\sql_backup\" \\\\bck_svr\\SQL_Backup \/mov \/s<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I am using Tara&#8217;s excellent\u00a0MsSQL Backup script\u00a0to backup my SQL databases. This is an excellent way to backup SQL DB&#8217;s if you have an SQL Express version installed. Heck, \u00a0 I even use this when higher SQL versions are installed (with maintenance plan possibilities and stuff). On top of that, I needed a script which [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[53,33,32],"tags":[52,37,50,51],"class_list":["post-163","post","type-post","status-publish","format-standard","hentry","category-backup-2","category-mssql","category-windows","tag-backup","tag-copy","tag-robocopy","tag-versioning"],"_links":{"self":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=163"}],"version-history":[{"count":8,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/163\/revisions"}],"predecessor-version":[{"id":193,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/163\/revisions\/193"}],"wp:attachment":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}