Set Archive bit for entire drive...?

K

Kenneth

Howdy,

What dos command will allow me to set the archive bit for every file
on a drive?

ATTRIB +a C:*.*

does it only for the root.

Is it:

ATTRIB +a C:*.* /s

Thanks for your help,
 
P

Pegasus \(MVP\)

Kenneth said:
Hello again,

It seems that ATTRIB +a C:*.* /s almost does it...

But, it does not set the archive bit for "hidden" files.

How can I get around that?

The reason, BTW, is that rather than doing a full backup to tape, I
want to do a full image to remote disk, followed by differential
backups to CDs. For that to work, I need to set the archive bit of
everything that was put in the image file.

Thanks in advance,

You probably have to unhide the hidden files in order to
set the archive attribute. This has some obvious drawbacks.

Instead of using the archive bit you could do a backup to
CD by date:

xcopy /s /y /h /d:08/13/2003 c:\*.* e:\

The process can be automated so that it picks up files
that were added or changed since the previous backup:

@echo off
set LogDir=c:\BackupLogs
set LogFile=%LogDir%\Backup.log

if not exist %LogDir% md %LogDir%
if exist %LogFile% for /F "tokens=2" %%a in (%LogFile%) do set Last=%%a
if not exist %LogFile% set Last=01/01/2003

xcopy /s /y /h /d:%Last% c:\*.* e:\
echo %date% (Date of last backup to CD) > %LogFile%
 
K

Kenneth

You probably have to unhide the hidden files in order to
set the archive attribute. This has some obvious drawbacks.

Hello again,

Unless I am missing something here, there would be no reason for me to
be concerned about hidden files at all... Because they are hidden, I
could not modify them.

If I ran a full disk image, set the archive bit of everything (other
than hidden files), and then ran a few differential backups to CD, it
would seem that I would have everything backed up: In the event of a
crash, the image I had made, would have everything including hidden
files, and the differential backup to Cd would have everything
modified since that time.

Is my reasoning on this correct?

Thanks again for your comments,
 
P

Pegasus \(MVP\)

Kenneth said:
Hello again,

Unless I am missing something here, there would be no reason for me to
be concerned about hidden files at all... Because they are hidden, I
could not modify them.

If I ran a full disk image, set the archive bit of everything (other
than hidden files), and then ran a few differential backups to CD, it
would seem that I would have everything backed up: In the event of a
crash, the image I had made, would have everything including hidden
files, and the differential backup to Cd would have everything
modified since that time.

Is my reasoning on this correct?

Thanks again for your comments,

You can reset the hidden flag of every file on the whole disk
by using the technique you used to set the archive bit.
However, I don't think you will get what you want.

Your backup method is only suitable for data files. It is not
suitable as a system backup, simply because there are
many locked files (e.g. the Registry) that you cannot backup
like this, and yet they are essential for the system.

To back up a whole system you have several options:
- Use a proper backup program, e.g. ntbackup.exe, and
select the appropriate options.
- Create an image file of your system drive, using a program
such as DriveImage or Ghost.
- Install dual booting and back up your main OS from the
secondary OS.
 
I

IOStorm

If I ran a full disk image, set the archive bit of everything (other
than hidden files), and then ran a few differential backups to CD, it
would seem that I would have everything backed up: In the event of a
crash, the image I had made, would have everything including hidden
files, and the differential backup to Cd would have everything
modified since that time.

Is my reasoning on this correct?

There would be no need to set the archive attributes. Ghost pays no
attention to it, it just backs up the whole drive or partition, bit
for bit.

Any file that is changed after the image is made will automatically
have the archive attribute set. That is a natural function of the
file system.

So all you need is an image, and then incremental backups
(differential backups don't turn the archive bit off). The first time
you do the incremental backup you'll pick up the files that had the
archive bit set when the image was made. So there would be some
redundancy. But only the first time.
 
K

Kenneth

Seeing that you intend to back up your whole drive, system files
and all, do you really want to persist with this script? As I said,
it will NOT touch your locked files.

Hello again,

No, it is not that I am invested in the script at all...

I am looking for a reasonable method that will allow me to replace my
current backup process (full backup to tape, followed by differential
backups to CD for a few days, then repeat) with full image to external
disk, followed by differential backups to CD for a few days, then
repeat.)

The hitch is that backup to tape sets the archive bit, but image to
external disk does not.

So, I have asked for approaches that will allow me to do what I
need...

Thanks again for any suggestions you might have,
 
P

Pegasus \(MVP\)

Kenneth said:
Hello again,

No, it is not that I am invested in the script at all...

I am looking for a reasonable method that will allow me to replace my
current backup process (full backup to tape, followed by differential
backups to CD for a few days, then repeat) with full image to external
disk, followed by differential backups to CD for a few days, then
repeat.)

The hitch is that backup to tape sets the archive bit, but image to
external disk does not.

So, I have asked for approaches that will allow me to do what I
need...

Thanks again for any suggestions you might have,

Do this:
1. Create a folder c:\Tools
2. Launch notepad.exe
3. Copy & past my lines of code into notepad.
4. Save the file as c:\Tools\KenBackup.bat
5. Use the Task Scheduler (it's in the Control Panel) to
schedule c:\Tools\KenBackup once every day / week /
month.
 
K

Kenneth

Do this:
1. Create a folder c:\Tools
2. Launch notepad.exe
3. Copy & past my lines of code into notepad.
4. Save the file as c:\Tools\KenBackup.bat
5. Use the Task Scheduler (it's in the Control Panel) to
schedule c:\Tools\KenBackup once every day / week /
month.

Very sincere thanks,
 
K

Kenneth

Do this:
1. Create a folder c:\Tools
2. Launch notepad.exe
3. Copy & past my lines of code into notepad.
4. Save the file as c:\Tools\KenBackup.bat
5. Use the Task Scheduler (it's in the Control Panel) to
schedule c:\Tools\KenBackup once every day / week /
month.

Hello again,

I got the routine to run, but it seems not to copy anything to the CD
(or as I now have it set up, to a floppy.

Here is the routine exactly as I have it:

@echo off
set LogDir=c:\BackupLogs
set LogFile=%LogDir%\Backup.log
if not exist %LogDir% md %LogDir%
if exist %LogFile% for /F "tokens=2" %%a in (%LogFile%) do set
Last=%%a
if not exist %LogFile% set Last=01/01/2003
xcopy /s /y /h /C:%Last% c:\*.* A:\
echo %date% (Date of last backup to CD) > %LogFile%


When I run it, there is a brief flash of a DOS screen and it does
establish Backup.log with today's date, but, it writes nothing to the
floppy.

I assume that the line:

xcopy /s /y /h /C:%Last% c:\*.* A:\

is to get the last date of backup from the Backup.log, then copy for
all subfolders, suppressing prompting, and for all hidden files, copy
everything changed since the last date of backup to the A:

Can you spot the reason it is not writing to A:?

Thanks again,
 
P

Pegasus \(MVP\)

Kenneth said:
Hello again,

I got the routine to run, but it seems not to copy anything to the CD
(or as I now have it set up, to a floppy.

Here is the routine exactly as I have it:

@echo off
set LogDir=c:\BackupLogs
set LogFile=%LogDir%\Backup.log
if not exist %LogDir% md %LogDir%
if exist %LogFile% for /F "tokens=2" %%a in (%LogFile%) do set
Last=%%a
if not exist %LogFile% set Last=01/01/2003
xcopy /s /y /h /C:%Last% c:\*.* A:\
echo %date% (Date of last backup to CD) > %LogFile%


When I run it, there is a brief flash of a DOS screen and it does
establish Backup.log with today's date, but, it writes nothing to the
floppy.

I assume that the line:

xcopy /s /y /h /C:%Last% c:\*.* A:\

is to get the last date of backup from the Backup.log, then copy for
all subfolders, suppressing prompting, and for all hidden files, copy
everything changed since the last date of backup to the A:

Can you spot the reason it is not writing to A:?

Thanks again,

In cases like these you should not retype the script but
use cut & paste to copy it from the news screen to your
notepad. This avoids errors, such as writing "C:" when
I wrote "D:"!

This time I will attach the batch file. Detach it and file it
in a suitable place.

I have added a PAUSE command to the end of the batch
file so that you can see what's going on. It is absolutely
essential that you remove the PAUSE line when using the
Task Scheduler to run your command!
 
K

Kenneth

In cases like these you should not retype the script but
use cut & paste to copy it from the news screen to your
notepad. This avoids errors, such as writing "C:" when
I wrote "D:"!

This time I will attach the batch file. Detach it and file it
in a suitable place.

I have added a PAUSE command to the end of the batch
file so that you can see what's going on. It is absolutely
essential that you remove the PAUSE line when using the
Task Scheduler to run your command!

Howdy,

I did cut & paste, but must have modified that line accidentally.

I will give your attached version a try, and again, offer my sincere
thanks,
 
K

Kenneth

In cases like these you should not retype the script but
use cut & paste to copy it from the news screen to your
notepad. This avoids errors, such as writing "C:" when
I wrote "D:"!

This time I will attach the batch file. Detach it and file it
in a suitable place.

I have added a PAUSE command to the end of the batch
file so that you can see what's going on. It is absolutely
essential that you remove the PAUSE line when using the
Task Scheduler to run your command!

Hello again,

Well, I am making progress (of a sort), but don't have it running
yet...

If I run it precisely as you sent it to me, I get the error:

Insufficient disk space on current disk. Insert another disk and type
<Return> to continue.

Assuming that the "current" disk is my "A" drive, I modified the code
(keeping your original version <g>) and changing the destination to
the I: drive which is my CD burner.

That give me the line:

xcopy /s /y /h /d:%Last% c:\*.* I:\

but when I run things that way, I get no error message, but nothing is
written to the CD.

Also, when I attempt to view the CD contents to see if something had
been written, I get the message "Please insert a disk into drive "I"."

Might that be because the CD in the burner is not formatted?

Next, I tried writing to a folder that I set up on a second internal
drive D: That folder is named BackupTest giving me:

xcopy /s /y /h /d:%Last% c:\*.* D:\BackupTest

That successfully copies boot.ini to the destination, but then hangs
with a sharing violation. The screen shows:

c:\boot.ini
c:\pagefile.sys
Sharing Violation
Press any key to continue.

When I press Enter, the DOS window closes...

In addition to all this, I realize that assuming I get it to copy
properly to the CD, I would need not only the date parameter, but a
time parameter as well. Doing the backup only once each day would not
be sufficient for my needs.

It also occurs to me that all of this started with my desire to do a
differential, (rather than an incremental) backup to CD. That would
mean that the date of the backup would not change in the log with each
use, but would simply be the date that I did the full disk image.
Then, when too many changed files accumulated to allow me to fit them
onto a CD, I would just do the full image again.

Related to that, can XCOPY span CDs? Or would it just give me an error
if I tried to put too much on one disk?

With all that, I am deeply appreciative of the assistance you have
already given me, and I certainly do not intend to impose.

If you can assist further, that would be great. If not, please accept
my thanks for all the help you have provided me thus far.

All the best,
 
P

Pegasus \(MVP\)

Kenneth said:
Hello again,

Well, I am making progress (of a sort), but don't have it running
yet...

If I run it precisely as you sent it to me, I get the error:

Insufficient disk space on current disk. Insert another disk and type
<Return> to continue.

Assuming that the "current" disk is my "A" drive, I modified the code
(keeping your original version <g>) and changing the destination to
the I: drive which is my CD burner.

That give me the line:

xcopy /s /y /h /d:%Last% c:\*.* I:\

but when I run things that way, I get no error message, but nothing is
written to the CD.

Also, when I attempt to view the CD contents to see if something had
been written, I get the message "Please insert a disk into drive "I"."

Might that be because the CD in the burner is not formatted?

Next, I tried writing to a folder that I set up on a second internal
drive D: That folder is named BackupTest giving me:

xcopy /s /y /h /d:%Last% c:\*.* D:\BackupTest

That successfully copies boot.ini to the destination, but then hangs
with a sharing violation. The screen shows:

c:\boot.ini
c:\pagefile.sys
Sharing Violation
Press any key to continue.

When I press Enter, the DOS window closes...

In addition to all this, I realize that assuming I get it to copy
properly to the CD, I would need not only the date parameter, but a
time parameter as well. Doing the backup only once each day would not
be sufficient for my needs.

It also occurs to me that all of this started with my desire to do a
differential, (rather than an incremental) backup to CD. That would
mean that the date of the backup would not change in the log with each
use, but would simply be the date that I did the full disk image.
Then, when too many changed files accumulated to allow me to fit them
onto a CD, I would just do the full image again.

Related to that, can XCOPY span CDs? Or would it just give me an error
if I tried to put too much on one disk?

With all that, I am deeply appreciative of the assistance you have
already given me, and I certainly do not intend to impose.

If you can assist further, that would be great. If not, please accept
my thanks for all the help you have provided me thus far.

All the best,

- To overcome your sharing violation problem, add the /c switch:
xcopy /c /s /y /h /d:%Last% c:\*.* D:\BackupTest

- To resolve your problem with copying to CD: I cannot help
you there. You must ensure that the CD can be written to,
before you invoke this batch file. The method depends entirely
on your CD writing software: Nero uses InCD, Roxio use DirectCD,
others use different approaches again.

- Backing up several times each day: xcopy can differentiate
between different dates but not between different times. To resolve
this issue you have two options:
a) Consider the archive bits (which was discussed before)
b) Use xxcopy.exe. This is a freeware program that has a large
number of switches. Be prepared to spend a couple of hours
getting up to speed on it.

- Spanning CDs: AFAIK only backup and compression programs can
span media, ntbackup.exe and WinZIP being two examples.
 
K

Kenneth

- To overcome your sharing violation problem, add the /c switch:
xcopy /c /s /y /h /d:%Last% c:\*.* D:\BackupTest

- To resolve your problem with copying to CD: I cannot help
you there. You must ensure that the CD can be written to,
before you invoke this batch file. The method depends entirely
on your CD writing software: Nero uses InCD, Roxio use DirectCD,
others use different approaches again.

- Backing up several times each day: xcopy can differentiate
between different dates but not between different times. To resolve
this issue you have two options:
a) Consider the archive bits (which was discussed before)
b) Use xxcopy.exe. This is a freeware program that has a large
number of switches. Be prepared to spend a couple of hours
getting up to speed on it.

- Spanning CDs: AFAIK only backup and compression programs can
span media, ntbackup.exe and WinZIP being two examples.

Howdy,

The"/C" switch was the charm...

I have decided that rather than copying to CD, it will be better for
me to copy to the external USB HD that will also include the total
image file.

But, because of that change, a modification is needed in addition to
changing the destination of the copy:

I would like to enter in the log file the date of the last image
creation and then just have the XCOPY pipe all files with later dates
to the file on the external drive.

How should I modify your script to do that (rather than the script
modifying the backup date each time it runs)?

Sincere thanks,
 
K

Kenneth

If you mean that you wish to be prompted for a date to be entered,
here it is:

@echo off
set LogDir=c:\BackupLogs
set LogFile=%LogDir%\Backup.log

if not exist %LogDir% md %LogDir%
if exist %LogFile% for /F "tokens=2" %%a in (%LogFile%) do set Last=%%a
if not exist %LogFile% set Last=01/01/2003

xcopy /s /y /h /d:%Last% c:\*.* e:\
set /p date_=Please enter a date for the log file:
echo %date_% (Date of last backup to CD) > %LogFile%
pause

Hmmm,

Well I modified the script you suggested by adding the "/C" switch and
changing the destination. The relevant line now looks like this:

xcopy /c /s /y /h /d:%Last% c:\*.* D:\BackupTest

When I run the script, it asks for the date, I enter it, it writes it
to the log file, but it copies nothing to the BackupTest folder.

There are no errors, but no data are copied.

Can you spot the problem?

Thanks again,
 
P

Pegasus \(MVP\)

Kenneth said:
Hmmm,

Well I modified the script you suggested by adding the "/C" switch and
changing the destination. The relevant line now looks like this:

xcopy /c /s /y /h /d:%Last% c:\*.* D:\BackupTest

When I run the script, it asks for the date, I enter it, it writes it
to the log file, but it copies nothing to the BackupTest folder.

There are no errors, but no data are copied.

Can you spot the problem?

Thanks again,

I strongly recommend that you spend some time in becoming
familiar with the way xcopy.exe works. If you write

xcopy /d:01/01/2003 . . .

then the command will copy every file that was created or modified
after 1 January 2003. If you now specify your own date (as opposed
to the previous backup date) then you will get a completely
different outcome.

You must also remember that xcopy expects a date in the form
of mm/dd/yyyy.

Start a Command Prompt and type this:

xcopy /? | more
 
K

Kenneth

I strongly recommend that you spend some time in becoming
familiar with the way xcopy.exe works. If you write

xcopy /d:01/01/2003 . . .

then the command will copy every file that was created or modified
after 1 January 2003. If you now specify your own date (as opposed
to the previous backup date) then you will get a completely
different outcome.

You must also remember that xcopy expects a date in the form
of mm/dd/yyyy.

Start a Command Prompt and type this:

xcopy /? | more
Hello again,

I have read about the XCOPY commands many times, and will, of course,
continue to try to get this running in the "automated" fashion you had
suggested to me.

Thanks again for all your help,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top