树莓派镜像文件备份不能启动_轻松在所有网络计算机上保留本地文件的镜像备份...

树莓派镜像文件备份不能启动

树莓派镜像文件备份不能启动

When you have a bunch of end user computers on a network, it is important to be sure files stored locally on the respective computers are backed up in the event of hard drive failure. Maintaining backup programs, configurations and, possibly, support costs on each machine can be a real pain, so as an alternative we have a simple solution: a script which, when run, mirrors local data to a common network location.

当网络上有一堆最终用户计算机时,确保硬盘驱动器发生故障时备份在各自计算机上本地存储的文件非常重要。 在每台机器上维护备份程序,配置以及可能的支持成本可能是一个真正的难题,因此,作为替代方案,我们有一个简单的解决方案:一个脚本,该脚本在运行时将本地数据镜像到公共网络位置。

怎么运行的 (How it Works)

Both the setup and mirror process are very simple and goes like this:

设置和镜像过程都非常简单,如下所示:

  1. Create and share a folder on your network where you would like the user files stored. Users will need read and write access to this folder.

    在网络上创建并共享一个文件夹,您要在其中存储用户文件。 用户将需要对该文件夹的读写权限。
  2. Place the backup script in the network share.

    将备份脚本放在网络共享中。
  3. Schedule a task on each user’s computer to run the backup script from the network share.

    在每个用户的计算机上计划任务以从网络共享运行备份脚本。
  4. The script mirrors the documents stored on the local machine to the network share.

    该脚本将存储在本地计算机上的文档镜像到网络共享。

The script utilizes the Microsoft RoboCopy tool and automatically creates the “/Computer Name/User Name” folder structure inside the network folder so user documents will not overwrite each other.

该脚本利用Microsoft RoboCopy工具,并在网络文件夹内自动创建“ /计算机名/用户名”文件夹结构,因此用户文档不会相互覆盖。

剧本 (The Script)

@ECHO OFF
TITLE Local Documents Backup
ECHO Local Documents Backup
ECHO Written by: Jason Faulkner
ECHO SysadminGeek.com
ECHO.
ECHO.

SETLOCAL EnableExtensions

REM RoboCopy.exe must be present on the client machine in a folder specified in the PATH variable.
REM For Windows Vista and later have this tool included, but Windows XP and earlier should download
REM this tool from Microsoft and place it in the Windows folder of their machine.

REM Root folder where backup files should be stored.
REM To use the directory containing this script, use: %~dp0
SET BackupDir=%~dp0

REM Message to users:
ECHO.
ECHO Running Local Documents Backup.
ECHO.
ECHO Do not close this window, it will close automatically when finished.
ECHO You can safely minimize this window and continue working.
ECHO.
ECHO.


REM Destination= Specified Backup FolderComputer NameWindows User Name
REM Create required folders if they do not exist
SET BackupDir=%BackupDir%%ComputerName%
SET BackupDir=%BackupDir:\=%
IF NOT EXIST "%BackupDir%" MKDIR "%BackupDir%"
SET BackupDir=%BackupDir%%UserName%
IF NOT EXIST "%BackupDir%" MKDIR "%BackupDir%"

SET LogFile="%BackupDir%%ComputerName%-%UserName%_BackupLog.txt"

ECHO %ComputerName% Backup Starting > %LogFile%
ECHO. >> %LogFile%
ECHO.

REM Call BackupDirectory with a relative folder name in the %UserProfile% directory
REM To view available directories, run this from the command prompt:
REM    DIR %UserProfile%
REM Add more directories as needed (i.e. "Downloads", "Favorites", etc.)

ECHO Backing up Documents...
REM Windows Vista / 7
CALL :BackupDirectory "Documents" >> %LogFile%
REM Windows 2000 / XP
CALL :BackupDirectory "My Documents" >> %LogFile%
ECHO Finished
ECHO.
ECHO Backing up Desktop...
CALL :BackupDirectory "Desktop" >> %LogFile%
ECHO Finished
ECHO.

ECHO.
ECHO.
GOTO End

ENDLOCAL


:BackupDirectory
ECHO.
REM Only backup this directory if it exists on the client machine
SET Source="%UserProfile%%~1"
IF NOT EXIST %Source% GOTO End
SET Dest="%BackupDir%%~1"
IF NOT EXIST %Dest% MKDIR %Dest%
REM Run the mirror copy:
RoboCopy %Source% %Dest% /V /S /E /COPY:DAT /PURGE /MIR /NP /R:1 /W:30
ECHO.
ECHO.
GOTO End

:End
 

在用户计算机上安排备份脚本 (Scheduling the Backup Script on User Machines)

Once the network share and batch script are in place, setting up a simple Scheduled Task is all you have to do on each client machine. This Scheduled Task which runs the script only requires a few special options which we will point out here.

一旦网络共享和批处理脚本就位,在每台客户端计算机上只需要做一个简单的计划任务即可。 运行脚本的此计划任务仅需要几个特殊选项,我们将在此处指出。

Because the script’s source and destination folders for the mirror process are driven by the Windows User Account, you will need to make sure the Scheduled Task runs under the respective user’s Windows login.

由于用于镜像过程的脚本的源文件夹和目标文件夹是由Windows用户帐户驱动的,因此您需要确保计划任务在相应用户的Windows登录名下运行。

If you have multiple users who utilize the same machine, you will need to set up a Scheduled Task for each user so the script. In situations like this, you may want to select the option to only have the script run when the user is logged in.

如果您有多个使用同一台计算机的用户,则需要为每个用户设置一个计划任务,因此需要设置脚本。 在这种情况下,您可能希望选择仅在用户登录时才运行脚本的选项。

image

Schedule the task to run whenever appropriate. You might want to consider having the process repeat several times throughout the day so changes are mirrored with the server often.

安排任务在适当的时候运行。 您可能需要考虑使该过程在一整天内重复几次,以便经常将更改反映到服务器上。

image

The program/script is the batch script stored on the network.

程序/脚本是存储在网络上的批处理脚本。

image

Since the backup can only run if a network connection is available, you can configure this option. This is optional because if the connection is not available the task will not run anyway because it cannot find the target program/script. Additionally, if you have the Scheduled Task set to run at a time when the computer may not be in use and/or asleep, select the option to wake the computer in order to run the task.

由于仅当网络连接可用时才可以运行备份,因此可以配置此选项。 这是可选的,因为如果连接不可用,则该任务将不会运行,因为它找不到目标程序/脚本。 此外,如果将“计划任务”设置为在计算机不使用和/或处于睡眠状态时运行,请选择唤醒计算机的选项以运行任务。

image

Configure advanced options as needed. One option of interest is “Run task as soon as possible after a scheduled start is missed” which will ensure backup intervals are not completely skipped in the event the machine is turned off.

根据需要配置高级选项。 感兴趣的一个选项是“错过计划的启动后尽快运行任务”,这将确保在关闭计算机的情况下不会完全跳过备份间隔。

image

结果 (The Result)

As we mentioned earlier, the first time the mirror process runs the folder structure is created and all documents from the configured source folders are copied to the network. Needless to say, the copy can take a while depending on the amount of data. Subsequent executions of the Schedule Task will complete much quicker as files from the local machine are added, updated and deleted as needed to keep the mirrored structure.

正如我们前面提到的,第一次运行镜像进程时,将创建文件夹结构,并将来自已配置源文件夹的所有文档复制到网络。 不用说,根据数据量的不同,复制可能需要一段时间。 随着本地计算机文件的添加,更新和删除,以保持镜像结构,计划任务的后续执行将更快完成。

image

链接 (Links)

Download BackupFiles Script from SysadminGeek.com

从SysadminGeek.com下载BackupFiles脚本

Download Windows Server 2003 Toolkit (which includes RoboCopy.exe) from Microsoft

从Microsoft 下载Windows Server 2003工具包 (包括RoboCopy.exe)

翻译自: https://www.howtogeek.com/51024/easily-keep-a-mirrored-backup-of-local-files-on-all-your-network-computers/

树莓派镜像文件备份不能启动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值