0

I am trying to learn scripting in Ubuntu.

I need to backup files created by a specific user in a folder where other users store there files. It needs to be compressed into a tar file with the file tree intact.

Edit: How do I find those files created by a user and then compressing them into a tar file with all the direcories and subdirectories

FILENAME=user_archive.tar
DESDIR=/home/user
FILES=find /shared -type d -user user * tar -rvf $DESDIR/$FILENAME
tar -jcvf $DESDIR/$FILENAME
Flows
  • 3,675
  • 3
  • 28
  • 52

1 Answers1

0

As suggested by @Cyrus and using shellcheck, you keep the following error

To assign the output of a command, use var=$(cmd)

Then you get some errors to correct and here a working script

FILENAME=user_archive.tar
DESDIR=/home/user
FILES=$(find /shared -type d -user user)
tar -jcvf $DESDIR/$FILENAME $FILES
Flows
  • 3,675
  • 3
  • 28
  • 52