Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to backup server data for up to 7 days?

Posted on 2014-03-20
8
681 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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
 
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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
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 how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

828 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