Choose style:

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

0 Members and 1 Guest are viewing this topic.

Offline emegra

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1885
  • Karma: 410
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 9 64bit
tarring with the same brush (SOLVED)
« on: April 25, 2019, 01:35:42 am »
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, 03: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

  • Trusted User
  • Veteran
  • *****
  • Posts: 1836
  • Karma: 257
    • View Profile
Re: tarring with the same brush
« Reply #1 on: April 25, 2019, 02:32:18 am »
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, 03:43:31 am by pin »

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25730
  • Karma: 2822
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: tarring with the same brush
« Reply #2 on: April 25, 2019, 07: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 ./shotwell
which 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 ./shotwell
but that's obviously for you to decide.
« Last Edit: April 25, 2019, 08: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

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1885
  • Karma: 410
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 9 64bit
Re: tarring with the same brush
« Reply #3 on: April 25, 2019, 03: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