$ tar cvfz my_dotfile_backup-$(date +"%Y-%m-%d").tar.gz --exclude .file_to_exclude --exclude .vscode ~/\.*
The above will:
- c = create a tarball
- v = verbose
- f = write the output to the specificed file
- z = compress the output file with gzip.
- Output filename will be "my_dotfile_backup-" + the date the command was run in YYYY-MM-DD format + ".tar.gz"
- Exclude files matching .file_to_exclude, and .vscode
- ~ = My home folder
- \.* Escaped dot character then wildcard (meaning the filename needs to start with a .)
$ ls -l my_dot*
-rw-r--r-- 1 arojas staff 30093272 Feb 28 12:17 my_dotfile_backup-2020-02-28.tar.gz