code: def compress_folder_dump(path, target):
      '''
      Compress folder dump to tar.gz file
      '''
      import tarfile
      if not path or not os.path.isdir(path):
          raise SystemExit(_error_codes.get(105))
      name_out_file = (target + 'dump-' +
                       datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))
      tar = tarfile.open(name_out_file + '.tar.gz', 'w:gz')
      tar.add(path, arcname='dump')
      tar.close()
      return (name_out_file, name_out_file + '.tar.gz'f compress_folder_dump(path, target):
      '''
      Compress folder dump to tar.gz file
      '''
      import tarfile
      if not path or not os.path.isdir(path):
          raise SystemExit(_error_codes.get(105))
      name_out_file = (target + 'dump-' +
                       datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))
      tar = tarfile.open(name_out_file + '.tar.gz', 'w:gz')
      tar.add(path, arcname='dump')
      tar.close()
      return (name_out_file, name_out_file + '.tar.gz')
docs: Compress folder dump to tar.gz file