Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

tar file with directory and single files

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
juliorollan
Posts: 17
Joined: 2016-08-23 16:22
Location: Argentina

tar file with directory and single files

#1 Post by juliorollan »

Hello. I'm stuck with the following issue. I made a backup script for Wordpress, which includes the installation directory and the database. They are stored in different paths.
At some point of the script, I create a tarball file including the directory and the sql flle with the command:

Code: Select all

tar -cf /path/to/archive.tar -C /path/to/wordpress/dir . /path/to/file.sql
The thing is that the Wordpress directory is archived under ./ in the tarball but the SQL file keeps its full path. I've been reading the tar manual, searched on the internet and tried several alternatives, but none seem to work.

I would like to concatenate, or append, the SQL file in the root of the tarball without the SQL's file full path.

Thanks in advance for your time.

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: tar file with directory and single files

#2 Post by bw123 »

I don't use tar much, kind of fun I guess, you want to do like this?

Code: Select all

$ ls path*
path1:
foo1.txt

path2:
foo2.txt

$ tar -cf archive.tar -C path1 . -C ../path2 foo2.txt

$ tar -tf archive.tar
./
./foo1.txt
foo2.txt
resigned by AI ChatGPT

juliorollan
Posts: 17
Joined: 2016-08-23 16:22
Location: Argentina

Re: tar file with directory and single files

#3 Post by juliorollan »

Closely, but path1 is a complete directory.
I use absolute paths because I don't know where the user is running the script in.

Post Reply