Questions

Create a batch file to backup the content

+
0 Votes
Locked

Create a batch file to backup the content

alok.behria
Hi All,

I need to create a batch file , which can copy the contects of one folder to other. for example, i have some folder which also contains other sub folder, now i need to backup all the sub folder of Alok and when I run it second time, then it should only backup the changes files or folders since the last copy.

Hare Krishna
Alok
  • +
    0 Votes
    XSive

    You can do this using a utilty called Robocopy (contender for one of the best utiltity names ever surely!)
    It's available with the resource kit, you can use the /MIR option to mirror the contents of the directory initially. Then create another batch file to only copy those files which are changed thereafter.

    +
    0 Votes
    123

    http://www.xs4all.nl/~redido/Robocopy%20script/

    +
    0 Votes
    Toivo Talikka

    How about just using XCOPY in a .bat or .cmd file?

    The first copy:
    d:
    cd \backup\servername
    xcopy \\servername\folder\*.* /e /q /c

    Subsequent copies:
    d:
    cd \backup\servername
    xcopy \\servername\folder\*.* /d /e /q /c /y

    You may want to remove everything from d:\backup\servername say once a month before the backup script is run, simply to get rid of obsolete files which have already been deleted from the server.

    +
    0 Votes
    mike

    this script first creates a backup then only copies increments (changes to the original backup)? Then flush the backup and repeat steps 1 & 2 on a monthly basis?

    +
    0 Votes
    atul_malviya07574

    nothing more special want to do this
    the begest hant for me to do
    so

    +
    0 Votes
    tonymonreal

    This Batch should work for what you need.
    I use it my self and it works pretty good
    All you need to do is Change the Drive and folder name to the ones you need to back up.
    It will copy the target folder and any subfolders in it and after the initial backup it will only backup any changes made.

    @echo off
    :: variables
    set backup=xcopy /s /c /d /e /h /i /r /y

    echo Backing up My Documents...
    %backup% D:\"My Documents" C:\"Back up"

    echo Backup Complete!
    @pause

  • +
    0 Votes
    XSive

    You can do this using a utilty called Robocopy (contender for one of the best utiltity names ever surely!)
    It's available with the resource kit, you can use the /MIR option to mirror the contents of the directory initially. Then create another batch file to only copy those files which are changed thereafter.

    +
    0 Votes
    123

    http://www.xs4all.nl/~redido/Robocopy%20script/

    +
    0 Votes
    Toivo Talikka

    How about just using XCOPY in a .bat or .cmd file?

    The first copy:
    d:
    cd \backup\servername
    xcopy \\servername\folder\*.* /e /q /c

    Subsequent copies:
    d:
    cd \backup\servername
    xcopy \\servername\folder\*.* /d /e /q /c /y

    You may want to remove everything from d:\backup\servername say once a month before the backup script is run, simply to get rid of obsolete files which have already been deleted from the server.

    +
    0 Votes
    mike

    this script first creates a backup then only copies increments (changes to the original backup)? Then flush the backup and repeat steps 1 & 2 on a monthly basis?

    +
    0 Votes
    atul_malviya07574

    nothing more special want to do this
    the begest hant for me to do
    so

    +
    0 Votes
    tonymonreal

    This Batch should work for what you need.
    I use it my self and it works pretty good
    All you need to do is Change the Drive and folder name to the ones you need to back up.
    It will copy the target folder and any subfolders in it and after the initial backup it will only backup any changes made.

    @echo off
    :: variables
    set backup=xcopy /s /c /d /e /h /i /r /y

    echo Backing up My Documents...
    %backup% D:\"My Documents" C:\"Back up"

    echo Backup Complete!
    @pause