China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-24 16:31
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Original] [XP] File Backup Utility V2.4 (Final) [Updated on 07-4-8] DigestI View 34,134 Replies 112
Floor 61 Posted 2006-06-29 22:59 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Because when backing up, in order to prevent changes to the files after backup, all files after backup have been set to "system + read-only" attributes. If the original attributes of these files are not restored when restoring the files, some unexpected problems will occur: for example, operations such as renaming and updating the content of the restored files can no longer be performed. This is also a problem I discovered when restoring the files, so the operation of attributes is added.

Of course, when backing up, the /k parameter can be used to maintain the original attributes, but after doing this, changes to the files after backup cannot be prevented. For the safety of backing up files, it is better to make it more complicated :)
Floor 62 Posted 2006-07-01 01:21 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
When replying to other posts, I checked the code for date detection in this script again. I found that if we want to detect the input of week - style dates, the principle is actually the same as that of digital - style date detection. It just needs to use a certain trick in the findstr command. So I immediately stayed up late to improve the date detection.
Floor 63 Posted 2006-07-03 00:26 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
There are still issues with the function of restoring files from backup files, mainly regarding the file naming problem. Please do not use this function for the time being. If you want to use it, manually modify the file name in the generated *_revert.bat file to avoid restoration errors.
Floor 64 Posted 2006-07-25 23:05 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Who is willing to come and improve this script? Mainly the part of restoring the backup.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 65 Posted 2006-07-26 09:30 ·  中国 辽宁 大连 教育网
中级用户
★★
DOS之友
Credits 332
Posts 168
Joined 2005-10-06 00:00
20-year member
UID 43171
Gender Male
From 天涯
Status Offline
I can only support you spiritually. We still need to work hard
测试环境: windows xp pro sp2 高手是这样炼成的:C:\WINDOWS\Help\ntcmds.chm
Floor 66 Posted 2006-07-28 22:32 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
The part of operating the backed-up files has been improved. Generally speaking, the basic functions of this script for backup purposes have been available. The remaining work mainly is to find bugs and streamline the code. I hope everyone is not intimidated by the large amount of code and all come to test it.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 67 Posted 2006-07-29 16:16 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re: namejm:

To be honest, I still don't agree with adding too many attribute operation codes to the program for the sake of protecting backup files. Because compared with the high cost of code and performance we put in, the probability that backups with various attributes are artificially modified and damaged won't be reduced much. This is also the main reason why I can't consider updating and testing the restore module.

Maybe only adding attributes to the target directory is a compromise. The effect is similar to the method of adding attributes to all targets, but the cost is much lower.

Of course, if you insist on the original view, then I put forward an improvement suggestion for the for statement in the get_attrib segment of attribute operation:


for %%a in (a s h r) do echo %%i|findstr "%%a">nul && set a%%a=+%%a || set a%%a=
echo attrib !aa!!ah!!ar!!as!%%j >>"%batch_directory%\%name%_revert.bat"


[ Last edited by willsort on 2006-7-29 at 23:46 ]
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 68 Posted 2006-07-29 22:29 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Re:

  The reason why I initially added the "System + Read-only" attribute to each target file was to make the system automatically prompt whether the user really wants to perform operations like deletion or renaming when they accidentally do so for one of the files. It wasn't intended to deal with deliberate destruction. If I really wanted to deal with deliberate destruction, I could use the method of md test.. to create a folder that can't be accessed or deleted by conventional methods to store backup files. However, I gave up this malicious idea considering that there might be a need to access the backed-up files : )

  If I only add attributes to the top-level target folder, the risk prevention ability is slightly weaker than the current plan, but the efficiency of setting up backup tasks is improved. There are both advantages and disadvantages. This version still keeps the current plan. Replace my original part with the simplified code you provided and see everyone's opinions first. Thanks for your continuous attention and code provision.

[ Last edited by namejm on 2006-8-1 at 01:17 ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 69 Posted 2006-07-29 23:46 ·  中国 山西 临汾 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re namejm:

Found one obvious and one less obvious error in the code at building 67. The code at building 67 and the top floor has been corrected.

There is a missing echo before attrib in the second sentence, and a space should be added after %%j; otherwise, it will error when %%j is a single digit.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 70 Posted 2006-07-30 14:40 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Hehe, willsort is really meticulous, even noticing such a细微 place. Under your prompt, I also discovered that this code should have added a line setlocal enabledelayedexpansion before, to avoid delay errors.

Tested the current code and found two relatively serious problems, both related to the parameter /s in the line xcopy /d /h /i /g /q /s /x /y "%source%" "%destination%":
1. When a file (not a folder) is in the root directory, sometimes the copy fails and prompts "Cannot perform periodic copy";
2. If there are files with the same name in the directory under the file to be copied, all the same-named files will be copied;

The key to solving problem 1 is to distinguish whether to copy a file or a folder when using xcopy;
And the solution to problem 2 is a bit tricky: if the parameter /s is removed, only the first-level files of the specified folder can be copied, and the subfolders under the folder cannot be copied; if the parameter /s is not removed, this problem cannot be avoided.

[ Last edited by namejm on 2006-7-30 at 23:07 ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 71 Posted 2006-07-31 23:23 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
May I ask the moderator if he can post the modified entire program for everyone to share?
Floor 72 Posted 2006-07-31 23:55 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
Moderators, can you release the entire modified program so that everyone can enjoy it?
Floor 73 Posted 2006-08-01 01:20 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
It took some time to solve the two problems on floor 70; when testing again, I found that in the line "for %%a in (a s h r) " by moderator willsort on floor 67, the "a" attribute seems a bit redundant because in testing it was found that any file has the "a" attribute, so there's no need to consider adding it with attrib again. This can save a lot of attribute operation code in the batch processing after restoring the backup; by the way, I also found and modified several errors.

Re chainliq:

From now on, both bat and exe format files will be provided for download at the top of the thread, with simple instructions. Thanks for your attention.

[ Last edited by namejm on 2006-8-1 at 01:38 ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 74 Posted 2006-09-15 05:40 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Looking forward to everyone's testing. If you have any questions, please post a reply. It needs everyone's joint participation.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 75 Posted 2006-09-15 06:13 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
To be honest, I haven't read this whole post yet. Oh, I need to go back and read it to learn.
Forum Jump: