Fluidbyte
Fluidbyte

Reputation: 5210

PHP tar returning path back to root

I'm running the following command to create a backup tarball of a file or folder:

system("tar -pczf /home/var/www/temp /home/var/www/folder/to/backup");

It works great, but when I extract I get the path all the way back to the root of the server (/home/var/www/folder/to/backup).

I'm curious if there's a command or flag which will allow me to create the tarball so it only contains the '/folder/to/backup' part.

Upvotes: 1

Views: 517

Answers (1)

Alain
Alain

Reputation: 36954

Yes, you can use relative paths :

system("tar -pczf /home/var/www/temp folder/to/backup");

Or if your backup directory is on a lower-level one :

system("tar -pczf /home/var/www/temp ../../folder/to/backup");

Some doc about relative/absolute paths.

Upvotes: 2

Related Questions