I am using the following command in a bash script for backup automation:
tar -vczf /tmp/${get_date}BACKUP${get_user}.tar.gz ${backup_dir[@]}
backup_dir
is an array in which user input is saved (the directories that will be backed up). If user input is illegal, it defaults to /home/$USER
.
The creation of a tar.gz works, but if a user types in multiple illegal directories, or if they chose to update the same directory multiple times, tar just backups all the files multiple times in the same folder, which makes it quite cumbersome to restore.
To avoid this, I am looking for a way to get tar to ignore duplicate input. Example:
tar -vczf /tmp/TEST.tar.gz /home/michael /home/michael
should be treated as tar -vczf /tmp/TEST.tar.gz /home/michael
Is it possible to do this?