Tuesday, May 14, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 4717  / 2 Years ago, thu, april 7, 2022, 5:22:02

Hi guys i am new to linux.


I am trying to create a tar file from a different directory and want to be placed a specific directory.


I have tried this cmd


tar -cvf dailybackup.tar /root/filesfromlocalmachine/ -C /root/backup/

There is a folder in the name pf backup and i want the tar to be created there. But whenever i execute this the tar is been created at the folder where i am executing the command. Is there a way to create a tar file from a different folder.


More From » command-line

 Answers
6

Yes, put the directory in front of the "tar".


cd /
tar -cvf /where/to/put/it/dailybackup.tar root/backup/

and it will backup root/backup.


I would suggest to always makes backups with a relative path (as I used in my answer) otherwise you might overwrite the destination when you wanted to restore it elsewhere and then do a compare with the backup version.


[#1144] Saturday, April 9, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
utonmbo

Total Points: 134
Total Questions: 104
Total Answers: 118

Location: Argentina
Member since Mon, Jan 3, 2022
2 Years ago
;