Linux 如何制作根文件系统的 tar 备份?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11395134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make a tar backup of a root filesystem?
提问by iabdalkader
I have linux installed on SD card, I used this command to install the rootfs
我在 SD 卡上安装了 linux,我用这个命令来安装 rootfs
tar xpjf rootfs.tar.bz -C /mnt/rootfs/
tar xpjf rootfs.tar.bz -C /mnt/rootfs/
Now, I made some changes to the rootfs and I would like to create a backup that I can use with the same command above, I tried using:
现在,我对 rootfs 进行了一些更改,我想创建一个备份,我可以使用上面相同的命令来使用它,我尝试使用:
tar cpjf rootfs.tar.bz2 /mnt/rootfs
and
tar cpjf rootfs.tar.bz2 -C / mnt/rootfs
I also tried
tar cpjf rootfs.tar.bz2 /mnt/rootfs/*
And tried:
并尝试:
cd /mnt/rootfs
tar -cvpjf rootfs.tar.bz2 --exclude=/rootfs.tar.bz2 .
tar: ./rootfs.tar.bz2: file changed as we read it
but I end up with an archive that has two levels before the file system i.e mnt/rootfs/files What am I doing wrong ?
但我最终得到的档案在文件系统之前有两个级别,即 mnt/rootfs/files 我做错了什么?
采纳答案by alex88
That's because it starts from current working directory, you can do:
那是因为它从当前工作目录开始,您可以执行以下操作:
cd /mnt/rootfs
tar cpjf /rootfs.tar.bz2 .
And that should create an archive at /rootfs.tar.bz2 with its root at the contents of /mnt/rootfs/
这应该在 /rootfs.tar.bz2 中创建一个存档,其根目录位于 /mnt/rootfs/ 的内容中