C:\\Users\\Administrator\\Downloads\\cos_migrate
unzip cos_migrate_tool_v5-master.zip && cd cos_migrate_tool_v5-master
COS_Migrate_tool|——conf #Directory of the configuration file| |——config.ini #Migration configuration file|——db #Store the record of successful migrations|——dep #JAR package complied by the main logic of the program|——log #Log generated during tool execution|——opbin #Script for compiling|——src #Source code of the tool|——tmp #Temporary file storage directory|——pom.xml #Project configuration file|——README #Readme document|——start_migrate.sh #Migration startup script for Linux|——start_migrate.bat #Migration startup script for Windows
db
directory mainly records the IDs of files successfully migrated by the tool. Each migration job will first compare the records in the db
directory. If the ID of the current file has already been recorded, the current file will be skipped, otherwise it will be migrated.log
directory keeps all the logs generated during tool migration. If an error occurs during migration, first check error.log
in this directory../conf/config.ini
) first. This file contains the following parts:type
indicates the migration type, which is filled in by users based on their migration needs. For example, to migrate local data to COS, users need to configure type=migrateLocal
for [migrateType]
.[migrateType]type=migrateLocal
Migration Type | Description |
migrateLocal | From local system to COS |
# The common configuration section of the migration tool includes account information to be migrated to the destination COS.[common]secretId=COS_SECRETIDsecretKey=COS_SECRETKEYbucketName=examplebucket-1250000000region=ap-guangzhoustorageClass=StandardcosPath=/https=offtmpFolder=./tmpsmallFileThreshold=5242880smallFileExecutorNum=64bigFileExecutorNum=8entireFileMd5Attached=ondaemonMode=offdaemonModeInterVal=60executeTimeWindow=00:00,24:00outputFinishedFileFolder=./resultresume=falseskipSamePath=false
Name | Description | Default Value |
secretId | SecretId of your key. Replace COS_SECRETID with your real key information, which can be obtained on the TencentCloud API key page in the CAM console | - |
secretKey | SecretKey of your key. Replace COS_SECRETKEY with your real key information, which can be obtained on the TencentCloud API key page in the CAM console | - |
bucketName | Name of the destination bucket in the format of <BucketName-APPID> . The bucket name must include the APPID such as examplebucket-1250000000 | - |
region | Region information of the destination bucket. For the region abbreviations in COS, see Regions and Access Domain Names | - |
storageClass | Storage class for the migrated data. Valid values: Standard , Standard_IA , Archive . For more information, see Storage Class Overview. | Standard |
cosPath | COS path to migrate to. / indicates to migrate to the root path of the bucket, /folder/doc/ indicates to migrate to /folder/doc/ in the bucket. If /folder/doc/ does not exist, a path will be created automatically | / |
https | Whether to transfer via HTTPS. on: Yes, off: No. It takes time to enable transfer via HTTPS, which is suitable for scenarios that demand high security. | off |
tmpFolder | The directory used to store temporary files when data is migrated from another cloud storage service to COS, which will be deleted after the migration is completed. The format must be an absolute path: The separator on Linux is /, such as /a/b/c The separator on Windows is \\, such as E:\\\\a\\\\b\\\\c The default value is the tmp directory in the path of the tool | ./tmp |
smallFileThreshold | Number of bytes as the threshold for small files. If the size is greater than or equal to this threshold, multipart upload is used; otherwise, simple upload is used. The default value is 5 MB | 5242880 |
smallFileExecutorNum | Concurrency for uploading small files (smaller than smallFileThreshold) via simple upload. Decrease the concurrency if files are uploaded to COS via public network with low bandwidth | 64 |
bigFileExecutorNum | Concurrency for uploading large files (greater than or equal to smallFileThreshold) via multipart upload. Decrease the concurrency if files are uploaded to COS via public network with low bandwidth | 8 |
entireFileMd5Attached | The migration tool calculates the MD5 of the entire file and stores it in the custom header "x-cos-meta-md5" of the file for subsequent verification, because the ETag of a large file uploaded to COS via multipart upload is not the MD5 of the entire file | on |
daemonMode | Whether to enable daemon mode. on: yes; off: no. In daemon mode, the program will keep performing synchronization. The synchronization interval is configured by the daemonModeInterVal parameter | off |
daemonModeInterVal | Time interval in seconds between two rounds of synchronization | 60 |
executeTimeWindow | Execution time window with a granularity in minute, which defines the time period when the migration tool runs jobs. For example: 03:30, 21:00 means that jobs will be run between 03:30 and 21:00, and the tool is in sleep mode at other times, when the migration will be paused and the progress will be retained until the next time window when the migration will resume automatically | 00:00,24:00 |
outputFinishedFileFolder | This directory stores the results of successful migration tasks, and result files are named by date, for example, ./result/2021-05-27.out , where ./result is the directory that is created. Each line in the result files is in the format of "Absolute path"\\t"File size"\\t"Last modified time" . If outputFinishedFileFolder is left empty, no results will be output. | ./result |
resume | Whether to continue with the result of the last run and traverse through the list of files from the source. The tool starts from scratch by default. | false |
skipSamePath | Whether to skip the current file if a file with the same name already exists in COS. By default, the tool does not skip the current file: it overwrites the existing file. | false |
[migrateType]
. For example, if the configuration item of [migrateType]
is type=migrateLocal
, users only need to configure the [migrateLocal]
section.# Configuration section for migration from a local system to COS[migrateLocal]localPath=E:\\\\code\\\\java\\\\workspace\\\\cos_migrate_tool\\\\test_dataexcludes=ignoreModifiedTimeLessThanSeconds=
Configuration Item | Description |
localPath | Absolute path of the local directory Linux uses a slash (/) as the delimiter, for example, /a/b/c .Windows uses two backlashes (\\) as the delimiter, for example, E:\\\\a\\\\b\\\\c .Note: You can enter only a directory path but not file path for this parameter; otherwise, an error will occur while parsing the target object name. In the case of cosPath=/ , the request will be incorrectly parsed into a bucket creation request. |
excludes | Absolute path of the directory or file to be excluded, meaning some directories or files under localPath are not to be migrated. Multiple absolute paths are separated by semicolons. If this is left blank, all files in localPath will be migrated |
ignoreModifiedTimeLessThanSeconds | Exclude files that have an update time less than a certain period of time from the current time (in seconds). This item is left blank by default, indicating files are not to be filtered by the time specified by lastmodified . It is suitable for scenarios where you run the migration tool while updating files and don't want files being updated to be migrated to COS. For example, if it is configured as 300 , only files updated at least 5 minutes ago will be uploaded. |
config.ini
file by running the following command:sh start_migrate.sh
sh start_migrate.sh -Dcommon.cosPath=/savepoint0403_10/
db
directories. Refer to db
information in the tool structure above.sectionName
is the section name of the configuration file. sectionKey
is the name of the configuration item in the section. sectionValue
is the value of the configuration item in the section. COS path to which data is migrated to should be in the format of -Dcommon.cosPath=/bbb/ddd.KV
in the leveldb
file under the db
directory. Before each migration, check whether the path to which data is migrated has been recorded in the db
directory. If yes, and its attribute is the same as that in db
, the migration will be skipped; otherwise, the migration will be executed. The attribute varies by migration type. For local migration, mtime
determines whether to migrate. For migration from other cloud storage services and bucket replication, the etag and length of the source file determine whether to migrate. Therefore, we search for records of successful migrations in the db
directory rather than in COS. If a file is deleted or modified via COSCMD or the console rather than the migration tool, the migration tool cannot detect this change, and the file will not be re-migrated.db
directory according to the specified migration type to determine whether upload is allowed.inprogress
indicates migration is in progress, skip
indicates skipped, fail
indicates failed, ok
indicates succeeded, and condition_not_match
indicates file fails to meet migration conditions (such as lastmodified
and excludes
) and is skipped. Details about the failure can be viewed in the error log. The execution process is as shown below:
Was this page helpful?