How to make a tar backup of a root filesystem? [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have linux installed on SD card, I used this command to install the 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:
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 ?

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/

Related

Uncompress tar.gz file [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
With the usage of wget command line I got a tar.gz file. I downloaded it in the root#raspberrypi. Is there any way to uncompress it in the /usr/src folder?
Use -C option of tar:
tar zxvf <yourfile>.tar.gz -C /usr/src/
and then, the content of the tar should be in:
/usr/src/<yourfile>
Try this:
tar -zxvf file.tar.gz
gunzip <filename>
then
tar -xvf <tar-file-name>

"tar --directory" won't work [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I want to create a tarball of files, but not include the directory name. I know there's another way to do it, but I want to know why this way is not working.
If I run the following to create the tarball comprised of a specific file, then it works:
tar -vcf file.tar -C <PATH TO DIR> file1
However, if I run it on a wild card to include multiple files, then it fails:
tar -vcf file.tar -C <PATH TO DIR> *
I get an error saying, for each file in the current dir (not the dir specified in -C), tar: <FILE>: Cannot stat: No such file or directory
Any idea why running the above command on a wild card vs a file name behaves differently?
The * wildcard is expanded by the shell before tar is invoked. tar then changes directory (because you asked it to), but then can't find the files that were in the shell's current directory.
Of course, changing directories in the shell means that you can't open the output file in the original current directory. So you have to redirect the output of tar outside of the subshell, like this:
(cd $DIR; tar -vc *) > file.tar
You have to use a directory:
tar -vcf files.tar /path/to/directory
If your files are in your folder, then use the . to reference the current folder:
tar -vcf files.tar .

How to strip path while archiving with TAR [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have a file that contain list of files I want to archive with tar.
Let's call it mylist.txt
It contains:
/path1/path2/file1.txt
/path1/path2/file3.txt
...
/path1/path2/file10.txt
What I want to do is to archive this file into a tarball but excluding /path1/path2/.
Currently by doing this:
tar -cvf allfiles.tar -T mylist.txt
preserves the path after unarchiving.
I tried this but won't work too:
tar -cvf -C /path1/path2 allfiles.tar -T mylist.txt
It archives all the files in /path1/path2 even those which are not in mylist.txt
Is there a way to do it?
In your "Extraction phase" you can use the strip-components flag like
tar xvf tarname.tar --strip-components=n
which will remove the first n leading components of the file name. Although if you have different file-path-components this will not work for all cases.
If you want to do it while archiving, only one thing comes to mind, and I will share
INPUT: list of files + full paths
1) for each line, split the path out of the filename
2) execute cd to that path and tar on that filename
3) repeat for each line

Using tar option to extract the contents of a rar file [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have uploaded a rar file under linux server .
When i used unrar -e filename.rar or rar -e filename.rar , i got this error Command not found rar.
As i am not a root user , i dont have permissions to install unrar Into linux machiene .
So please tell me is it possible to use tar option to extract the contents of a rar file ??
When i used unrar under Linux machiene i got this
-bash-3.00$ unrar
-bash: unrar: command not found
-bash-3.00$
Thank you
You must install the unrar or unrar-free packets from a repository.

tar --files-from complains "Cannot stat: No such file or directory" [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
When I type " tar -cvf ~/changeset.tar --files-from ~/changeset.txt", It responds with this output: http://pastie.org/1071080. Here is the contents of ~/changeset.txt: http://pastie.org/1071084 . In other words, a bunch of relative paths. As a sanity check,
$ ls admin/memberinformation.php admin/memberinformation.php
Why can't tar find any of these files even though they are clearly reachable from the current directory with the relative paths given?
FYI: $ tar --version tar (GNU tar) 1.15.1
The clue is the position of the colon in the tar output.
You've got a bad case of the trailing spaces. Get rid of them in your changeset file.

Resources