0

I have a python script that is running in two places, two different, but similar commands:

os.system("tar cf - -C %s . 2>/dev/null 3>/dev/null | 7za a -p%s -si %s 1>/dev/null 2>/dev/null 3>/dev/null" % (cf, self.config.get(jn, "archpass"), filename))


os.system("tar -Jchf - -C %s . 2>/dev/null 3>/dev/null | 7za a -p%s -si %s 1>/dev/null 2>/dev/null 3>/dev/null" % (cf, self.config.get(jn, "archpass"), filename))

This script is used to backup websited on a Ubuntu server. So most of files are html/php/js/jpg. I need to understand this command more in order to have an idea if there is place for improvement.

Question 1) What's the difference between: tar cf and tar -Jchf. Unfortunately tar --help didn't help me understand the additional -Jf parameters.

Question 2) Is tar also archiving? What could be the purpose of sending everything to 7za? Is it doing a double archivisation?

Pikk
  • 187
  • 1
  • 6

1 Answers1

2

The actual difference in the commands are the Jh switches, which are described here (from man tar):

-h, --dereference
              Follow symlinks; archive and dump the files they point to.
-J, --xz
              Filter the archive through xz(1).

So you're forcing the archive to be compressed with xz and following symlinks instead of archiving the links themselves.

ajgringo619
  • 3,113
  • 1
  • 11
  • 37