Author Topic: tarring with the same brush (SOLVED)  (Read 515 times)

Offline emegra

  • Administrator
  • Veteran
  • *****
  • Posts: 1946
  • Karma: 450
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 10 64bit
tarring with the same brush (SOLVED)
« on: April 24, 2019, 10:35:42 pm »
HI guys

I'm trying to write a simple script to backup my Shotwell database which resides at  ~/.local/share/shotwell
so I want to create an tarball of the shotwell directory that I can extract to ~/.local/share

so if I run the following command

Code: [Select]
sudo tar -cf ~/shotwell-backup.tar ~/.local/share/shotwell
I get this message

Code: [Select]
graeme@Linux1 ~ $ sudo tar -cf ~/shotwell-backup.tar ~/.local/share/shotwell
tar: Removing leading `/' from member names
graeme@Linux1 ~ $


However it creates the tarball at ~/ but when I extract it I get a folder called "home" with subfolders  /graeme/.local/share/shotwell, but I only want the shotwell directory

what am I doing wrong ?

I don't have to do it this way i could simply copy the folder with

Code: [Select]
sudo cp -r ~/.local/share/shotwell ~/shotwell.bakup
but I'm curious to know what I'm doing wrong






« Last Edit: April 25, 2019, 12:53:52 pm by emegra »
If you can keep your head while all around are losing theirs then you're not quite grasping the situation

Offline pin

  • Veteran
  • ****
  • Posts: 1838
  • Karma: 280
    • View Profile
Re: tarring with the same brush
« Reply #1 on: April 24, 2019, 11:32:18 pm »
You're most probably just missing the -C switch. See, https://linux.die.net/man/1/tar

Hope it helps.
« Last Edit: April 25, 2019, 12:43:31 am by pin »

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26452
  • Karma: 65531
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: tarring with the same brush
« Reply #2 on: April 25, 2019, 04:07:59 am »
Code: [Select]
tar -cf ~/shotwell-backup.tar -C ~/.local/share/shotwell .note the -C option which basically changes the current directory for you, and "." at the end which basically means 'start from the current directory'.

This will tar the CONTENTS of the ~/.local/share/shotwell directory only (not the parent directory itself).

It's the single line equivalent of:
Code: [Select]
cd ~/.local/share/shotwell
tar -cf ~/shotwell-backup.tar .
BTW, you shouldn't need 'sudo' to do this as you're creating the tarball in your own home folder.



If you don't just want the CONTENTS, but also want the parent ~/.local/share/shotwell directory
Code: [Select]
tar -cf ~/shotwell-backup.tar -C ~/.local/share ./shotwellwhich is the single line equivalent of:
Code: [Select]
cd ~/.local/share
tar -cf ~/shotwell-backup.tar ./shotwell

[EDIT]

Personally I'd have created a tar.gz .. so:
Code: [Select]
tar -czf ~/shotwell-backup.tar.gz -C ~/.local/share ./shotwellbut that's obviously for you to decide.
« Last Edit: April 25, 2019, 05:04:46 am by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline emegra

  • Administrator
  • Veteran
  • *****
  • Posts: 1946
  • Karma: 450
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 10 64bit
Re: tarring with the same brush
« Reply #3 on: April 25, 2019, 12:53:25 pm »
Thank you guys You've been a great help

I'll mark this solved




Graeme
If you can keep your head while all around are losing theirs then you're not quite grasping the situation