Warning

 

Close

Confirm Action

Are you sure you wish to do this?

Confirm Cancel
BCM
User Panel

Posted: 6/22/2015 8:59:40 PM EDT
I need a batch file to backup 5 shared drives and send that to a 6th drive creating a date named folder with the contents of the other drives all within this folder.

Drives: J, K, L ,M ,N and the Backup drive is S.

It's been a long time since I've had to make batch files and have done some quick testing that looks like it will work.
I want all files including empty folders and hidden files to copy into the newly created backup folder.

What parameters should I be using for "xcopy" to accomplish this task?  I read that Win 7 upgraded parameters with xcopy.  I will be running the batch file on a Win 8.1 system.

TIA xcopy guru's.

Add what I'm working on currently:
@echo off
::variables
set backupcmd=xcopy /s /c /d /e /h /i /r /y
set dirname="%date:~10,4%_%date:~4,2%_%date:~7,2%_backup"
mkdir S:\%dirname%

echo ### Backing up drive1 Documents...
%backupcmd% "J:\*.*" "S:\%dirname%\drive1"
echo ### Backing up drive2 Documents...
%backupcmd% "K:\*.*" "S:\%dirname%\drive2"
echo ### Backing up drive3 Documents...
%backupcmd% "L:\*.*" "S:\%dirname%\drive3"
echo ### Backing up drive4 Documents...
%backupcmd% "M:\*.*" "S:\%dirname%\drive4"
echo ### Backing up drive5 Documents...
%backupcmd% "N:\*.*" "S:\%dirname%\drive5"

echo Backup Complete!
@pause
Link Posted: 6/22/2015 10:03:47 PM EDT
[#1]
Why batch and not powershell?  Also why not any of the bajillion pieces of software that will do this for free without scripting?
Link Posted: 6/22/2015 11:37:33 PM EDT
[#2]
#System Variable for backup Procedure


$date = Get-Date -Format d.MMMM.yyyy
New-PSDrive -Name "Backup" -PSProvider Filesystem -Root "\\BackupServer\Backups"
$source = "D:\Data\"
$destination = "backup:\$date"
$path = test-Path $destination

#Email Variables

$smtp = "Exchange-server"
$from = "Backup <[email protected]>"
$to = "The User <[email protected]>"
$body = "Log File of backup is attached, backup happens on of Date: $date"
$subject = "Backup on $date"

# Backup Process started

if ($path -eq $true) {
   write-Host "Directory Already exists"
   Remove-PSDrive "Backup"  
   } elseif ($path -eq $false) {
           cd backup:
           mkdir $date
           copy-Item  -Recurse $source -Destination $destination
           $backup_log = Dir -Recurse $destination | out-File "$destination\backup_log.txt"
           $attachment = "$destination\backup_log.txt"
#Send an Email to User
           send-MailMessage -SmtpServer $smtp -From $from -To $to -Subject $subject -Attachments $attachment -Body $body -BodyAsHtml
           write-host "Backup Sucessfull"
           cd c:

Remove-PSDrive "Backup"  
}
Link Posted: 6/22/2015 11:52:42 PM EDT
[#3]
I remembered writing batch files for backing up files in the Win 95, 98 and NT days.  Over the years I've gotten soft on scripting not having to use it at all for daily operations.  Funny what a little hardware failure gets you to give a try out of the comfort zone.

I ran the batch file and things are working.  It should complete sometime in the next 4 hours.  One thing I noticed some of the folder properties are pulling the current date not carrying their original creation date.
Link Posted: 6/23/2015 12:55:46 AM EDT
[#4]
Does this mean you're not going to use my powershell script?
Link Posted: 6/23/2015 2:04:48 AM EDT
[#5]
I saw the same Powershell script you posted in the first link on a Google search "Powershell backup".  As stated on that page, it was never tested in Win 8 (the OS I'm running the batch file on) nor had it covered basically anything I was asking about.

Still looking for suggestions regarding the Win 7+ xcopy parameters.
Link Posted: 6/23/2015 2:21:39 AM EDT
[#6]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
I saw the same Powershell script you posted in the first link on a Google search "Powershell backup".  As stated on that page, it was never tested in Win 8 (the OS I'm running the batch file on) nor had it covered basically anything I was asking about.

Still looking for suggestions regarding the Win 7+ xcopy parameters.
View Quote


Command Prompt is going to be depreciated.  Best start learning PowerShell now.
Link Posted: 6/23/2015 3:34:03 PM EDT
[#7]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Still looking for suggestions regarding the Win 7+ xcopy parameters.
View Quote

The xcopy params look OK.

I learned something new with the substring notation.
Link Posted: 6/23/2015 8:09:32 PM EDT
[#8]
Discussion ForumsJump to Quoted PostQuote History
Quoted:


Command Prompt is going to be depreciated.  Best start learning PowerShell now.
View Quote View All Quotes
View All Quotes
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Quoted:
I saw the same Powershell script you posted in the first link on a Google search "Powershell backup".  As stated on that page, it was never tested in Win 8 (the OS I'm running the batch file on) nor had it covered basically anything I was asking about.

Still looking for suggestions regarding the Win 7+ xcopy parameters.


Command Prompt is going to be depreciated.  Best start learning PowerShell now.

They can have my command prompt when they pry my cold, dead fingers from it.
Link Posted: 6/23/2015 8:39:35 PM EDT
[#9]
Try FreeFileSync,  We use it for all kinds of stuff.  Excellent tool to have.
Link Posted: 6/23/2015 11:35:20 PM EDT
[#10]
Discussion ForumsJump to Quoted PostQuote History
Quoted:

They can have my command prompt when they pry my cold, dead fingers from it.
View Quote View All Quotes
View All Quotes
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Quoted:
Quoted:
I saw the same Powershell script you posted in the first link on a Google search "Powershell backup".  As stated on that page, it was never tested in Win 8 (the OS I'm running the batch file on) nor had it covered basically anything I was asking about.

Still looking for suggestions regarding the Win 7+ xcopy parameters.


Command Prompt is going to be depreciated.  Best start learning PowerShell now.

They can have my command prompt when they pry my cold, dead fingers from it.


Why? PowerShell is soooooooo much better.
Link Posted: 6/24/2015 4:04:04 PM EDT
[#11]

Discussion ForumsJump to Quoted PostQuote History
Quoted:
Why? PowerShell is soooooooo much better.
View Quote View All Quotes
View All Quotes
Discussion ForumsJump to Quoted PostQuote History
Quoted:



Quoted:


Quoted:


Quoted:

I saw the same Powershell script you posted in the first link on a Google search "Powershell backup".  As stated on that page, it was never tested in Win 8 (the OS I'm running the batch file on) nor had it covered basically anything I was asking about.



Still looking for suggestions regarding the Win 7+ xcopy parameters.




Command Prompt is going to be depreciated.  Best start learning PowerShell now.


They can have my command prompt when they pry my cold, dead fingers from it.




Why? PowerShell is soooooooo much better.
This, however I am just learning, it can do so much but there is a pretty good learning curve.



 
Link Posted: 6/24/2015 5:17:52 PM EDT
[#12]
Discussion ForumsJump to Quoted PostQuote History
Quoted:


Why? PowerShell is soooooooo much better.
View Quote View All Quotes
View All Quotes
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Quoted:
Quoted:
Quoted:
I saw the same Powershell script you posted in the first link on a Google search "Powershell backup".  As stated on that page, it was never tested in Win 8 (the OS I'm running the batch file on) nor had it covered basically anything I was asking about.

Still looking for suggestions regarding the Win 7+ xcopy parameters.


Command Prompt is going to be depreciated.  Best start learning PowerShell now.

They can have my command prompt when they pry my cold, dead fingers from it.


Why? PowerShell is soooooooo much better.

Old habits. Actually, I've never so much as looked at PS. Most of what I could conceive using it for is most likely something I'd do in Linux or Cygwin.
Link Posted: 6/24/2015 5:27:05 PM EDT
[#13]
robocopy > xcopy
Link Posted: 6/24/2015 5:53:28 PM EDT
[#14]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
robocopy > xcopy
View Quote
Listen to this man. He knows what he speaks. He speaks words of iron.
Link Posted: 6/25/2015 10:56:46 AM EDT
[#15]
Looking into it more, I'm definitely going to change out using xcopy to robocopy for my scheduled tasks.  Backups have been going smooth so far.  I had been adjusting the script date-name folder format and found that is dependent on your system's short date format setting.  If you change your short date setting it can mess with the date-name output of the backup folder.

The suggestion for FreeFileSync looks like a great addition to the software toolbox.  Thanks

This is my 4th backup system in use now for my servers. I've burned out a tape backup system and two separate DVD/RW systems with backup software.  Yesterday I got authorization to order new servers to replace the old servers, yeah.  They are a little long in the legs running since 2003 on Linux.  I've recorded uptimes at just over 750 days and for a 24/7 use operation that's pretty good.
Close Join Our Mail List to Stay Up To Date! Win a FREE Membership!

Sign up for the ARFCOM weekly newsletter and be entered to win a free ARFCOM membership. One new winner* is announced every week!

You will receive an email every Friday morning featuring the latest chatter from the hottest topics, breaking news surrounding legislation, as well as exclusive deals only available to ARFCOM email subscribers.


By signing up you agree to our User Agreement. *Must have a registered ARFCOM account to win.
Top Top