火狐自动化测试文件_如何使用批处理文件轻松自动化Firefox配置文件备份

火狐自动化测试文件

火狐自动化测试文件

Your Firefox profile houses some pretty important stuff such as bookmarks, saved passwords and preferences which would be quite inconvenient to lose. As with any valuable data, your Firefox profile should be backed up regularly.

您的Firefox配置文件中包含一些非常重要的内容,例如书签,保存的密码和首选项,这很容易丢失。 与任何有价值的数据一样,应定期备份Firefox配置文件。

While you can always perform the backup manually or use an external tool (such as MozBackup or FEBE), each of these options have their own shortcomings and none are a true “set it and forget it” method. Our geek oriented solution to Firefox profile backups is to use a batch script which can be run at any time. Regardless of whether or not you have Firefox open, this script will capture your current Firefox profile and store it in a zip file for easy recovery.

尽管您始终可以手动执行备份或使用外部工具(例如MozBackup或FEBE),但是每个选项都有其自身的缺点,没有一个是真正的“设置后遗忘”方法。 我们针对Firefox配置文件备份的极客解决方案是使用可随时运行的批处理脚本。 无论您是否打开Firefox,此脚本都将捕获您当前的Firefox配置文件并将其存储在一个zip文件中,以便于恢复。

剧本 (The Script)

Overall, the script doesn’t do anything magical. It simply goes to the respective user’s Firefix profile folder and copies all the unlocked files to a temporary directory and finally creates a zip archive of the files. You will need to have the 7-Zip command line tool copied to a folder set in your Windows PATH variable in order for the zip process to complete.

总体而言,该脚本没有任何神奇的作用。 它只是转到相应用户的Firefix配置文件文件夹,然后将所有未锁定的文件复制到一个临时目录,最后创建这些文件的zip存档。 您需要将7-Zip命令行工具复制到Windows PATH变量中设置的文件夹中,以便完成zip处理。

@ECHO OFF
TITLE Firefox Profile Backup
ECHO Firefox Profile Backup
ECHO Written by: Jason Faulkner
ECHO SysadminGeek.com
ECHO.
ECHO.

SETLOCAL

REM Requires the 7-Zip command line tool (7za.exe) which can be downloaded at:
REM http://www.7-zip.org
REM This file should be placed in a folder in the PATH variable (i.e. C:Windows)

REM Full path the the storage archive file (do not put in quotes)
REM Make sure this directory path exists.
SET BackupFileName=%USERPROFILE%DocumentsBackupFirefoxProfile.zip

REM Leave everything below here alone

SET TempBackupDir=%TEMP%Firefox_Profile
SET TempBackupDirAction="%TempBackupDir%"
IF EXIST %TempBackupDirAction% RMDIR %TempBackupDirAction%

MKDIR %TempBackupDirAction%
XCOPY "%APPDATA%MozillaFirefoxProfiles*" %TempBackupDirAction% /E /V /C /H /Y

SET BackupFileName="%BackupFileName%"
IF EXIST %BackupFileName% DEL /F /Q %BackupFileName%
7ZA a %BackupFileName% "%TempBackupDir%*"

IF EXIST %TempBackupDirAction% RMDIR /S /Q %TempBackupDirAction%

ENDLOCAL
@ECHO OFF
TITLE Firefox Profile Backup
ECHO Firefox Profile Backup
ECHO Written by: Jason Faulkner
ECHO SysadminGeek.com
ECHO.
ECHO.

SETLOCAL

REM Requires the 7-Zip command line tool (7za.exe) which can be downloaded at:
REM http://www.7-zip.org
REM This file should be placed in a folder in the PATH variable (i.e. C:Windows)

REM Full path the the storage archive file (do not put in quotes)
REM Make sure this directory path exists.
SET BackupFileName=%USERPROFILE%DocumentsBackupFirefoxProfile.zip

REM Leave everything below here alone

SET TempBackupDir=%TEMP%Firefox_Profile
SET TempBackupDirAction="%TempBackupDir%"
IF EXIST %TempBackupDirAction% RMDIR %TempBackupDirAction%

MKDIR %TempBackupDirAction%
XCOPY "%APPDATA%MozillaFirefoxProfiles*" %TempBackupDirAction% /E /V /C /H /Y

SET BackupFileName="%BackupFileName%"
IF EXIST %BackupFileName% DEL /F /Q %BackupFileName%
7ZA a %BackupFileName% "%TempBackupDir%*"

IF EXIST %TempBackupDirAction% RMDIR /S /Q %TempBackupDirAction%

ENDLOCAL

安排备份 (Scheduling the Backup)

Once you have the script in place, you simply need to schedule it via the Windows Task Scheduler. You can use the graphical interface or via the command line tool, SchTasks, to easily set it to run daily for the current user:

一旦脚本到位,您只需要通过Windows Task Scheduler计划它。 您可以使用图形界面或通过命令行工具SchTasks轻松地将其设置为对当前用户每天运行:

SchTasks /Create /SC DAILY /TN BackupFirefoxProfile /TR %UserProfile%DocumentsScriptsBackupFirefoxProfile.bat /ST 09:00 /RU <UserName> /RP <Password>

SchTasks /创建/ SC DAILY / TN BackupFirefoxProfile / TR%UserProfile%DocumentsScriptsBackupFirefoxProfile.bat / ST 09:00 / RU <用户名> / RP <密码>

Important Note: The script makes reference to profile specific locations (%USERPROFILE% and %APPDATA%), so it is important the scheduled task runs as the respective user account you want to backup the Firefox profile for.

重要说明:该脚本引用了配置文件的特定位置(%USERPROFILE%和%APPDATA%),因此计划任务以您要为其备份Firefox配置文件的相应用户帐户运行非常重要。

局限性 (Limitations)

This script will pick up any unlocked file as part of the backup. When Firefox is open, a file named “parent.LOCK” is created and this file is not included in the backup. It is a zero byte, so bit-wise the profile backup can complete without including this file.

该脚本将提取所有未锁定的文件作为备份的一部分。 打开Firefox后,将创建一个名为“ parent.LOCK”的文件,并且该文件不包含在备份中。 它是一个零字节,因此按位配置文件备份可以完成而无需包含此文件。

Certain add-ons may also lock files while Firefox is open, but our testing has not found any instances where this is the case.

Firefox打开时,某些附加组件也可能会锁定文件,但是我们的测试未找到任何这种情况。

Download the 7-Zip Command Line Tool

下载7-Zip命令行工具

Manually Backup a Firefox Profile

手动备份Firefox配置文件

FEBE Add-on for Firefox

Firefox的FEBE附加组件

翻译自: https://www.howtogeek.com/52049/how-to-easily-automate-your-firefox-profile-backup-with-batch-files/

火狐自动化测试文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值