Rancid/VieWVC - cvs - 只保留最新版本/删除旧版本

Posted

技术标签:

【中文标题】Rancid/VieWVC - cvs - 只保留最新版本/删除旧版本【英文标题】:Rancid/VieWVC - cvs - keep only latest revisios/ remove older versions 【发布时间】:2020-05-06 08:09:49 【问题描述】:

我使用 Rancid 和 ViewVC 作为“前端”来查看网络设备的配置文件

我只想保留所有设备的最新版本号,并删除旧版本

cvs -d /usr/local/rancid/var/CVS rlog Switches

输出示例:

RCS file: /usr/local/rancid/var/CVS/Switches/configs/Attic/1.1.1.1,v
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: o
total revisions: 3;     selected revisions: 3
description:
----------------------------
revision 1.3
date: 2020/01/17 11:39:40;  author: rancid;  state: dead;  lines: +0 -0
deleted router 1.1.1.1
----------------------------
revision 1.2
date: 2020/01/17 11:00:14;  author: rancid;  state: Exp;  lines: +2 -0
updates
----------------------------
revision 1.1
date: 2020/01/17 08:23:44;  author: rancid;  state: Exp;
new router
=============================================================================

RCS file: /usr/local/rancid/var/CVS/Switches/configs/1.1.1.2,v
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: o
total revisions: 2;     selected revisions: 2
description:
----------------------------
revision 1.2
date: 2020/01/20 07:29:34;  author: rancid;  state: Exp;  lines: +578 -0
updates
----------------------------
revision 1.1
date: 2020/01/17 11:57:40;  author: rancid;  state: Exp;
new router
=============================================================================

RCS file: /usr/local/rancid/var/CVS/Switches/configs/1.1.1.3,v
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: o
total revisions: 2;     selected revisions: 2
description:
----------------------------
revision 1.2
date: 2020/01/17 11:39:57;  author: rancid;  state: Exp;  lines: +535 -0
updates
----------------------------
revision 1.1
date: 2020/01/17 11:39:39;  author: rancid;  state: Exp;
new router
=============================================================================

RCS file: /usr/local/rancid/var/CVS/Switches/configs/1.1.1.4,v
head: 1.10
branch:
locks: strict
access list:
symbolic names:
keyword substitution: o
total revisions: 10;    selected revisions: 10
description:
----------------------------
revision 1.10
date: 2020/01/16 13:42:54;  author: rancid;  state: Exp;  lines: +245 -0
updates
----------------------------
revision 1.9
date: 2020/01/16 13:42:44;  author: rancid;  state: Exp;  lines: +0 -245
new router
----------------------------
revision 1.8
date: 2020/01/16 13:41:20;  author: rancid;  state: dead;  lines: +0 -0
deleted router 1.1.1.4
----------------------------
revision 1.7
date: 2020/01/16 13:37:12;  author: rancid;  state: Exp;  lines: +245 -0
updates
----------------------------
revision 1.6
date: 2020/01/16 13:37:05;  author: rancid;  state: Exp;  lines: +0 -245
new router
----------------------------
revision 1.5
date: 2020/01/16 13:29:54;  author: rancid;  state: dead;  lines: +0 -0
deleted router 1.1.1.4
----------------------------
revision 1.4
date: 2020/01/16 11:33:03;  author: rancid;  state: Exp;  lines: +245 -0
updates
----------------------------
revision 1.3
date: 2020/01/16 11:23:45;  author: rancid;  state: Exp;  lines: +0 -0
new router
----------------------------
revision 1.2
date: 2020/01/16 11:16:27;  author: rancid;  state: dead;  lines: +0 -0
deleted router 1.1.1.4
----------------------------
revision 1.1
date: 2020/01/16 11:00:01;  author: rancid;  state: Exp;
new router

只是为了测试,来自/usr/local/rancid我试过

cvs -d /usr/local/rancid/var/CVS admin -o :"1.1" Switches

但是得到

cvs admin: /usr/local/rancid/var/CVS/Switches/configs/1.1.1.2,v: Revision rev 1.1 doesn't exist

尝试使用特定文件:

cvs -d /usr/local/rancid/var/CVS admin -o :"1.1" Routers/configs/1.1.1.1,v

 cvs -d /usr/local/rancid/var/CVS admin -o :"1.1" /usr/local/rancid/var/CVS/Routers/configs/1.1.1.1,v 

但是得到

cvs admin: cannot open CVS/Entries for reading: No such file or directory
cvs admin: nothing known about 1.1.1.1,v

【问题讨论】:

【参考方案1】:

好的,想通了,只需要退出`/usr/local/rancid/var/'路径,例如/tmp

然后输入cvs -d /usr/local/rancid/var/CVS checkout Switches

然后执行

cvs -d /usr/local/rancid/var/CVS admin -o :1.1 Switches/config/1.1.1.1

1.1 的所有修订都被删除

【讨论】:

以上是关于Rancid/VieWVC - cvs - 只保留最新版本/删除旧版本的主要内容,如果未能解决你的问题,请参考以下文章

我可以将单个文件从 CVS 迁移到 SVN 吗?

将许多 CVS 模块转换为单个 SVN 存储库

从 CVS 检出文件中获取有关 CVS 服务器的信息

从 CVS 重新导入到 Subversion

使用cvs2svn迁移cvs至svn

CVS 到 Subversion 的转换:磁盘空间问题