Solved

How to backup server data for up to 7 days?

Posted on 2014-03-20
8
627 Views
Last Modified: 2014-03-28
This is using MS windows 2003 and MS Windows 2008 R2 servers. I need to come out a backup script (preferably using batch or robocopy) to backup selective server data into a storage. We need to keep 7-day worth of data, so those backup data that more than 7 days ago, would have to be deleted. How can I do that?

Thanks in advance.
0
Comment
Question by:MichaelBalack
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 13

Expert Comment

by:Norm Dickinson
ID: 39941926
Your best bet is to install a professional backup software which allows customizable features such as this. My favorite is http://www.acronis.com. There are also a number of cloud backup services available for a reasonable price, depending upon the volume of data being backed up, such as Rackspace.com's Jungle Disk, or Mozy.com for example.
0
 
LVL 16

Expert Comment

by:gurutc
ID: 39942057
Hi,

I'm assuming you want to do a direct copy, is that correct?  Also, do you need all of the metadata or can you just do with the file data?  

Do you want to have 7 separate copies of the data, one for each day?  Or are you backing up copies of ever-changing files and only want one copy of file that has changed at any time in the last 7 days all in one backup folder?

Batch-Driven Robocopy is great.  But there are also other options such as Deltacopy which is an rsync wrapper for Windows.  It will save you a ton of time by only copying the changed blocks of files.

DeltaCopy-rsync for Windows

Depending on your answers to the questions I can offer some examples.

- gurutc
0
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 39942969
If your backup is already running daily from a script, and you just need to keep 7 copies, add code like this to the beginning of your backup script.

@echo off

if exist \path\to\backup7  rmdir /s /q  \path\to\backup7
if exist \path\to\backup6  ren  \path\to\backup6 \path\to\backup7
if exist \path\to\backup5  ren  \path\to\backup5 \path\to\backup6
if exist \path\to\backup4  ren  \path\to\backup4 \path\to\backup5
if exist \path\to\backup3  ren  \path\to\backup3 \path\to\backup4
if exist \path\to\backup2  ren  \path\to\backup2 \path\to\backup3
if exist \path\to\backup1  ren  \path\to\backup1 \path\to\backup2
if exist \path\to\backup   ren  \path\to\backup  \path\to\backup1

:: Then run today's backup script, putting it into \path\to\backup.

Open in new window


With the above code, backup1 will always have your backup from 1 day ago, backup5 will always have your backup from 5 days ago, etc.
0
 
LVL 1

Author Comment

by:MichaelBalack
ID: 39948893
Hi ThomasMCA2,

Thanks for your script. I would rather prefer to create a backup folder that bearing with date. For example a folder named: server_backup_24032014, for backup on that day. Would it be possible?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 14

Assisted Solution

by:ThomasMcA2
ThomasMcA2 earned 249 total points
ID: 39949009
Yes, using %date to build the name of the backup folder.

The example below follows your requested date format of DDMMYYYY. However, if you use YYYYMMDD, your folders will be sorted/organized by date when sorted by name.

@echo off

:: script to build DDMMYYYY as a file name

set year=%date:~-4%
set month=%date:~3,2%

:: Make sure the month uses 2 digits
if "%month:~0,1%" == " " set month=0%month:~1,1%

set day=%date:~0,2%
if "%day:~0,1%" == " " set day=0%day:~1,1%

set folder_name=server_backup_%day%%month%%year%

:: now use %folder_name% as the destination folder name, like this:

ren todays_backup_folder %folder_name%

Open in new window

0
 
LVL 16

Accepted Solution

by:
gurutc earned 251 total points
ID: 39950032
Your only issue now is to remove the old backup folders.

ForFiles /P C:backups  /D -7 /C “CMD /C if @ISDIR==TRUE echo RD /Q @FILE &RD /Q /S @FILE”

Since your backup folders will have the same creation date as the date in their name this should do the trick.

- gurutc
0
 
LVL 1

Author Comment

by:MichaelBalack
ID: 39951977
Hi everyone,

Thanks for the suggestiion. I will try and wait for my updates.
0
 
LVL 1

Author Closing Comment

by:MichaelBalack
ID: 39960904
It works
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now