Linux RepoSync将yum存储库同步到本地目录

当同步开始时,RepoSync下载存储库的索引,并将它们与开始时为空的当前索引进行比较,它为每个新的、删除的或修改的包或索引创建一个操作。它每次下载一个包以减少存储需求,对其进行验证,然后将它写入目标存储库。该过程在所有新包写入后写入并上传索引,因此新索引中引用的每个包都将立即可用。上传后,RepoSync将使CloudFront缓存中的修改文件(如果配置了)失效。然后RepoSync删除旧索引和删除的包,因为新索引已经可用,作为最后一步,它在本地将新索引写入本地新索引,这将在下一次同步中使用。如果在同步过程中的任何一点发生了失败,例如校验和不匹配或I/O错误,RepoSync将中断同步并删除下载的索引。对于RepoSync,同步从未发生过,并将在下一次迭代中从头开始执行所有操作。

RepoSync用于将远程yum存储库同步到使用yum检索包的本地目录。

reposync使用yum库来检索信息和包。如果没有指定配置文件,将使用默认的yum配置。
/etc/yum.conf
/etc/yum/repos.d/

reposync 命令将本地项目目录与清单中指定的远程存储库同步。如果本地项目还不存在,它将从远程存储库克隆一个新的本地目录,并设置清单中指定的跟踪分支。如果本地项目已经存在,reposync 将更新远程分支,并在新的远程更改之上重新建立任何新的本地更改。

reposync 将同步命令行中列出的所有项目。项目可以按名称指定,也可以按项目本地目录的相对路径或绝对路径指定。如果没有指定项目,'reposync’将同步清单中列出的所有项目。

语法

/usr/bin/reposync [options]

参数选项说明

  -c CONFIG, --config=CONFIG			指定配置文件运行(默认配置文件是 /etc/yum.conf )
  -a ARCH, --arch=ARCH                  就像运行指定的arch(默认值:当前arch,注意:不会覆盖$releasever,X86_64是i*86的超集)
  --source              操作源包
  -r REPOID, --repoid=REPOID			指定要查询的repo ids,可指定多次(默认为全部启用)
  -e CACHEDIR, --cachedir=CACHEDIR		存储元数据的目录
  -t, --tempcache      					使用临时目录来存储/访问yum-cache
  -d, --delete         					删除存储库中不再存在的本地包
  -p DESTDIR, --download_path=DESTDIR	下载包的路径:默认为当前目录
   			  --norepopath             不要将reponame添加到下载路径。只能在同步单个存储库时使用 (default is to add the reponame)
  -g, --gpgcheck        			    下载后删除未通过GPG签名检查的包
  -u, --urls            				只列出要下载的网址,不要下载
  -n, --newest-only     				只下载最新的包,相同的跳过
  -q, --quiet           				尽量少输出
  -l, --plugins         				启用yum插件支持
  -m, --downloadcomps  					同时下载 comps.xml
  --download-metadata   				下载所有non-default metadata
  --allow-path-traversal				允许同步存储在其repo目录之外的包 (UNSAFE, USE WITH CAUTION!)

举例

♥ 同步指定源到指定目录(yum repolist查看id)

[root@master ~]# reposync  --repoid=[仓库ID] -p /root/pac

♥ Sync all packages from the ‘updates’ repo to the current directory:

reposync --repoid=updates

♥ Sync only the newest packages from the ‘updates’ repo to the current directory:

 reposync -n --repoid=updates

♥ Sync packages from the ‘updates’ and ‘extras’ repos to the current directory:

  reposync --repoid=updates --repoid=extras

♥ Sync all packages from the ‘updates’ repo to the repos directory:

 reposync -p repos --repoid=updates

♥ Sync all packages from the ‘updates’ repo to the repos directory excluding x86_64 arch. Edit /etc/yum.conf adding option exclude=*.x86_64. Then:

reposync -p repos --repoid=updates

Don’t back up, you still have a chance!

猜你喜欢

转载自blog.csdn.net/qq_50573146/article/details/129922553