-1

I have a bunch of sub-directories of daily log files generated by my web application. Ideally what I would like to achieve is if given a path to a parent directory (i.e.)~/myapp/logs/july-logs/ the tool creates individual zip files of every single day sub-directory (i.e.) 11.07.23-myapp-logs.zip, 12.07.23-myapp-logs.zip etc. I have attached a screenshot for better understanding of the directory structure.

I have tried multiple times to find a tool on the Internet and gone through Github to find a repo where someone has developed a similar solution but no LUCK. I just want someone who knows how this can be done to point me in the right direction. I am ready to write a tool that can solve my problem from scratch and I posted a question here to make sure I am not reinventing the wheel.

fakhar
  • 1
  • 1

1 Answers1

0

tar -cvf backup.tar /path/to/backup

  • I used your command to create a .tar file however it just creates an archive of the entire directory does not create .tar files of the sub-directories. Screenshot for reference. Listing the contents tar -tvf backup.tar https://imgur.com/a/j5Nnyyg – fakhar Jul 12 '23 at 03:35
  • From your logs directory try this tar -cvf may-logs.tar ./may-logs && tar -cvf june-logs.tar ./june-logs && tar -cvf july-logs.tar ./july-logs && tar -cvf logs.tar *.tar && mv logs.tar ../logs.tar && rm *.tar. should be seperated logs now located within myapp directory. – Charles Henington Jul 12 '23 at 07:13