Solved

How to backup server data for up to 7 days?

Posted on 2014-03-20
8
698 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
[X]
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
  • 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

756 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