https://github.com/allwaysoft/fuse-copyfs
2020-10-25 修改后可以在fedora32上成功编译安装
fedora32上编译安装需要安装如下依赖:
dnf install fuse fuse-devel
dnf install perl-Algorithm-Diff
dnf install perl-Time-HiRes
测试版本控制成功
[root@localhost fs]# ls
'How to run Hyper.doc' test
[root@localhost fs]# pwd
/mnt/fs
[root@localhost fs]#
[root@localhost fs]# copyfs-fversion test
File test ('*' is active) :
Wide character in print at /usr/bin/copyfs-fversion line 532.
v1.0 : -rw-r--r-- root root 3 2020年10月25日 星期日 13时58分19秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v2.0 : -rw-r--r-- root root 3 2020年10月25日 星期日 13时58分44秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v3.0 : -rw-r--r-- root root 3 2020年10月25日 星期日 14时04分55秒 [*]
[root@localhost fs]# ls
'How to run Hyper.doc' test
[root@localhost fs]# copyfs-fversion 'How to run Hyper.doc'
File How to run Hyper.doc ('*' is active) :
Wide character in print at /usr/bin/copyfs-fversion line 532.
v1.0 : -rw-r--r-- root root 224768 2019年11月20日 星期三 11时39分33秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v2.0 : -rw-r--r-- root root 225792 2020年10月25日 星期日 14时09分56秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v3.0 : -rw-r--r-- root root 225792 2020年10月25日 星期日 14时09分51秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v4.0 : -rw-r--r-- root root 225792 2020年10月25日 星期日 14时12分18秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v5.0 : -rw-r--r-- root root 225792 2020年10月25日 星期日 14时12分06秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v6.0 : -rw-r--r-- root root 225792 2020年10月25日 星期日 14时12分56秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v7.0 : -rw-r--r-- root root 225280 2020年10月25日 星期日 14时12分50秒 [*]
[root@localhost fs]# copyfs-fversion -l 4.0 'How to run Hyper.doc'
[root@localhost fs]# copyfs-fversion 'How to run Hyper.doc'
File How to run Hyper.doc ('*' is active) :
Wide character in print at /usr/bin/copyfs-fversion line 532.
v1.0 : -rw-r--r-- root root 224768 2019年11月20日 星期三 11时39分33秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v2.0 : -rw-r--r-- root root 225792 2020年10月25日 星期日 14时09分56秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v3.0 : -rw-r--r-- root root 225792 2020年10月25日 星期日 14时09分51秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v4.0 : -rw-r--r-- root root 225792 2020年10月25日 星期日 14时12分18秒 [*]
Wide character in print at /usr/bin/copyfs-fversion line 532.
v5.0 : -rw-r--r-- root root 225792 2020年10月25日 星期日 14时12分06秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v6.0 : -rw-r--r-- root root 225792 2020年10月25日 星期日 14时12分56秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v7.0 : -rw-r--r-- root root 225280 2020年10月25日 星期日 14时12分50秒
[root@localhost fs]#
文件实际存储路径中的内容
[root@localhost fs]# cd /var/versions/
[root@localhost versions]# ls -arlt
总用量 1620
-rwx------. 1 root root 224768 11月 20 2019 '00000001.How to run Hyper.doc'
drwxr-xr-x. 21 root root 4096 10月 25 13:53 ..
-rwx------. 1 root root 22 10月 25 13:54 metadata.
-rw-------. 1 root root 47 10月 25 13:58 metadata..test.swpx
-rwx------. 1 root root 0 10月 25 13:58 00000001..test.swpx
-rwx------. 1 root root 0 10月 25 13:58 00000001..test.swp
-rw-------. 1 root root 46 10月 25 13:58 metadata..test.swp
-rwx------. 1 root root 0 10月 25 13:58 00000002..test.swp
-rwx------. 1 root root 3 10月 25 13:58 00000001.test
-rwx------. 1 root root 0 10月 25 13:58 00000001.4913
-rw-r--r--. 1 root root 3 10月 25 13:58 00000001.test~
-rw-r--r--. 1 root root 3 10月 25 13:58 00000002.test
-rwx------. 1 root root 0 10月 25 14:04 00000002.4913
-rw-------. 1 root root 68 10月 25 14:04 metadata.4913
-rw-r--r--. 1 root root 3 10月 25 14:04 00000002.test~
-rw-------. 1 root root 81 10月 25 14:04 metadata.test
-rw-r--r--. 1 root root 3 10月 25 14:04 00000003.test
-rw-------. 1 root root 70 10月 25 14:04 metadata.test~
-rwx------. 1 root root 225792 10月 25 14:09 '00000003.How to run Hyper.doc'
-rwx------. 1 root root 225792 10月 25 14:09 '00000002.How to run Hyper.doc'
-rwx------. 1 root root 225792 10月 25 14:12 '00000005.How to run Hyper.doc'
-rwx------. 1 root root 225792 10月 25 14:12 '00000004.How to run Hyper.doc'
-rwx------. 1 root root 225280 10月 25 14:12 '00000007.How to run Hyper.doc'
-rwx------. 1 root root 225792 10月 25 14:12 '00000006.How to run Hyper.doc'
-rw-------. 1 root root 301 10月 25 14:12 'metadata.How to run Hyper.doc'
-rw-------. 1 root root 4 10月 25 14:27 'dfl-meta.How to run Hyper.doc'
drwxr-xr-x. 2 root root 4096 10月 25 14:27 .
文件内容不变,属性改变版本号点后面加1
[root@localhost subdir]# chmod 777 *
[root@localhost subdir]# copyfs-fversion test
File test ('*' is active) :
Wide character in print at /usr/bin/copyfs-fversion line 532.
v1.0 : -rw-r--r-- root root 2 2020年10月25日 星期日 14时43分48秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v2.0 : -rw-r--r-- root root 2 2020年10月25日 星期日 14时44分23秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v3.0 : -rw-r--r-- root root 4 2020年10月25日 星期日 14时59分01秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v4.0 : -rw-r--r-- root root 2 2020年10月25日 星期日 15时03分00秒
Wide character in print at /usr/bin/copyfs-fversion line 532.
v4.1 : -rwxrwxrwx root root 2 2020年10月25日 星期日 15时03分00秒 [*]
[root@localhost subdir]#
CopyFS是未维护的。但是仍然可以下载。它是在GPL下发布的,因此您可以根据需要随时使用新版本。
原始版本文件:
增强版本文件:
https://github.com/cognusion/fuse-copyfs
增强版本CopyFS README文件
,ad8888ba, 88888888888 ad88888ba
d8"' `"8b 88 d8" "8b
d8' 88 Y8,
88 ,adPPYba, 8b,dPPYba, 8b d8 88aaaaa `Y8aaaaa,
88 a8" "8a 88P' "8a `8b d8' 88""""" `"""""8b,
Y8, 8b d8 88 d8 `8b d8' 88 `8b
Y8a. .a8P "8a, ,a8" 88b, ,a8" `8b,d8' 88 Y8a a8P
`"Y8888Y"' `"YbbdP"' 88`YbbdP"' Y88' 88 "Y88888P"
88 d8'
88 d8'
A copy-on-write, versionned filesystem
Version 1.3.1M
By
Nicolas Vigier
(boklm@mars-attacks.org)
and
Thomas Joubert
(widan@net-42.eu.org)
http://n0x.org/copyfs/
Contributions From:
Matthew Keller
CopyFS aims to solve a common problem : given a directory, especially one
full of configuration files, or other files that one can modify, and which
can affect the functionning of a system, or of programs, that may be important
to other users (or to the user himself), how to be sure that a person
modifying the files will do a backup of the working version first ?
This filesystem solves the problem by making the whole process transparent,
automatically keeping versionned copies of all the changes done to file under
its control.
It also allows a user to select an old version of the files, for example to
repair a mistake, and allows him/her to continue edition from this point.
CopyFS is distributed under the terms of the GNU GPL.
System requirements
-------------------
Filesystem in Userspace (FUSE) is required to use this filesystem. FUSE
was merged into the mainstream Linux kernel tree in kernel version 2.6.14,
so any version >= 2.6.14 should be fine, if the option was selected when
the kernel was compiled.
More informations about FUSE is available on http://fuse.sourceforge.net/
It might work on FreeBSD and OpenSolaris too, but we never tried yet.
How to install
--------------
Simply do :
copyfs-1.0 % ./configure
copyfs-1.0 % make all
copyfs-1.0 % su
Password:
copyfs-1.0 # make install
How to use
----------
To mount a CopyFS, you need to use the command 'copyfs-mount' : if you want to
mount a CopyFS at '/mnt/fs', whose version directory is at /var/versions, you
would use :
root # copyfs-mount /var/versions /mnt/fs
To unmount it, simply do :
root # umount /mnt/fs
As you would do for any filesystem.
Accessing old versions
----------------------
To know which versions are available, you can use the copyfs-fversion tool :
cpy-fs $ copyfs-fversion test
File test ('*' is active) :
v1.0 : -rw-r--r-- widan users 0 Fri Dec 10 14:17:47 2004
v2.0 : -rw-r--r-- widan users 21 Fri Dec 10 14:17:55 2004
v2.1 : -rwx------ widan users 21 Fri Dec 10 14:17:55 2004
v3.0 : -rwx------ widan users 29 Fri Dec 10 14:19:35 2004 [*]
You know there are 4 versions, with their associated information. In that state
you are viewing version 3.0 (ie the last one). If you want to see another one,
you can 'lock' it :
cpy-fs $ cat test
version 3.0
cpy-fs $ copyfs-fversion -l 2.0 test
cpy-fs $ cat test
version 2.0
If you want to remove the version lock, and return to the latest version
available, use :
cpy-fs $ copyfs-fversion -r test
Tagging files
-------------
Let's say you have the following file tree :
cpy-fs $ copyfs-fversion somedir/file-1
File file-1 ('*' is active) :
v1.0 : -rw-r--r-- widan users 3 Fri Dec 10 14:21:41 2004
v2.0 : -rw-r--r-- widan users 3 Fri Dec 10 14:21:43 2004 [*]
v3.0 : -rw-r--r-- widan users 3 Fri Dec 10 14:21:45 2004
cpy-fs $ copyfs-fversion somedir/file-2
File file-2 ('*' is active) :
v1.0 : -rw-r--r-- widan users 5 Fri Dec 10 14:21:51 2004 [*]
v2.0 : -rw-r--r-- widan users 5 Fri Dec 10 14:21:53 2004
cpy-fs $ copyfs-fversion somedir/file-3
File file-3 ('*' is active) :
v1.0 : -rw-r--r-- widan users 5 Fri Dec 10 14:21:58 2004
v2.0 : -rw-r--r-- widan users 5 Fri Dec 10 14:22:03 2004 [*]
You have :
cpy-fs $ cat somedir/file-1
v2
cpy-fs $ cat somedir/file-2
2 v1
cpy-fs $ cat somedir/file-3
3 v2
Suppose you want to save all the "current" versions for the directory
'somedir', you can create a tag file with :
cpy-fs $ copyfs-fversion -t tag-file somedir
Then you can edit the files as you want, and if you want to put all the files
back to the version they were at when you tagged them, simply do :
cpy-fs $ copyfs-fversion -u tag-file somedir
Example :
cpy-fs $ echo "new 1" > somedir/file-1
cpy-fs $ echo "new 2" > somedir/file-2
cpy-fs $ cat somedir/file-{1,2,3}
new 1
new 2
3 v2
cpy-fs $ copyfs-fversion -t tag-file-new somedir
cpy-fs $ copyfs-fversion -u tag-file somedir
Restored somedir/file-1 to version 2.0
Restored somedir/file-2 to version 1.0
Restored somedir/file-3 to version 2.0
cpy-fs $ cat somedir/file-{1,2,3}
v2
2 v1
3 v2
cpy-fs $ copyfs-fversion -u tag-file-new somedir
Restored somedir/file-1 to version 6.0
Restored somedir/file-2 to version 3.0
Restored somedir/file-3 to version 2.0
cpy-fs $ cat somedir/file-{1,2,3}
new 1
new 2
3 v2
Viewing the changes between version of text files
-------------------------------------------------
Example:
[workspace]$ echo "Hello world" > testfile
[workspace]$ echo "There's always room for JELLO" >> testfile
[workspace]$ copyfs-fversion testfile
File testfile ('*' is active) :
v1.0 : -rw-rw-r-- kellermg kellermg 12 Mon 13 Feb 2006 12:59:28 PM EST
v2.0 : -rw-rw-r-- kellermg kellermg 42 Mon 13 Feb 2006 12:59:55 PM EST [*]
[workspace]$ copyfs-fversion -d 1.0,2.0 testfile
2 -
2 + There's always room for JELLO
--------
[workspace]$ cat testfile
Hello world
There's always room for JELLO
We will balk if you try to diff a binary file:
[copyfs]$ copyfs-fversion -d 41.0,53.0 copyfs-daemon
I will not diff binary files
Searching (ala grep) for a pattern in all version of a text file
----------------------------------------------------------------
Example:
[workspace]$ echo "Hello world" > testfile
[workspace]$ echo "There's always room for JELLO" >> testfile
[workspace]$ echo "Thanks for all the fish" >> testfile
[workspace]$ echo "So long" >> testfile
[workspace]$ echo "Blah Blah Blah" >> testfile
[workspace]$ echo "Another fish" >> testfile
[workspace]$ copyfs-fversion -G fish testfile
Do not mess with this file... search in progress...
v3.0: Thanks for all the fish
v4.0: Thanks for all the fish
v5.0: Thanks for all the fish
v6.0: Thanks for all the fish
v6.0: Another fish
5 results.
You can also search for a regexp!:
[workspace]$ copyfs-fversion -G ^Blah testfile
Do not mess with this file... search in progress...
v5.0: Blah Blah Blah
v6.0: Blah Blah Blah
2 results.
Purging (Culling) old versions of files
---------------------------------------
Purging of folders not yet supported... maybe someday. The recursions necessary scares me.
Example:
[workspace]$ copyfs-fversion testfile
File testfile ('*' is active) :
v1.0 : -rw-rw-r-- kellermg kellermg 12 Mon 13 Feb 2006 12:59:28 PM EST
v2.0 : -rw-rw-r-- kellermg kellermg 42 Mon 13 Feb 2006 12:59:55 PM EST
v3.0 : -rw-rw-r-- kellermg kellermg 66 Mon 13 Feb 2006 01:03:24 PM EST
v4.0 : -rw-rw-r-- kellermg kellermg 74 Mon 13 Feb 2006 01:04:44 PM EST
v5.0 : -rw-rw-r-- kellermg kellermg 89 Mon 13 Feb 2006 01:04:56 PM EST
v6.0 : -rw-rw-r-- kellermg kellermg 102 Mon 13 Feb 2006 01:05:02 PM EST [*]
[workspace]$ copyfs-fversion -p 3 testfile
[workspace]$ copyfs-fversion testfile
File testfile ('*' is active) :
v4.0 : -rw-rw-r-- kellermg kellermg 74 Mon 13 Feb 2006 01:04:44 PM EST
v5.0 : -rw-rw-r-- kellermg kellermg 89 Mon 13 Feb 2006 01:04:56 PM EST
v6.0 : -rw-rw-r-- kellermg kellermg 102 Mon 13 Feb 2006 01:05:02 PM EST [*]
Or you can just kill the very existance of the file:
[workspace]$ copyfs-fversion -p A testfile
[workspace]$ copyfs-fversion testfile
fversion: testfile: No such file or directory