How to backup tar for root file system?

I have Linux installed on the SD card, I used this command to install rootfs

tar xpjf rootfs.tar.bz -C / mnt / rootfs /

Now I made some changes to rootfs, and I would like to create a backup that I can use with the same command above, I tried to use:

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 in the end I have an archive that has two levels in front of the file system. i.e. mnt / rootfs / files. What am I doing wrong?

+4
source share
1 answer

That, since it starts with the current working directory, you can do:

 cd /mnt/rootfs tar cpjf /rootfs.tar.bz2 . 

And this should create an archive on /rootfs.tar.bz2 with its root in the contents of / mnt / rootfs /

+7
source

All Articles