tarup.sh is a versatile Bash script designed to create tarball archives of directories with optional exclusion of certain files and directories. It supports custom exclusion sets and generates tarballs with a default filename format that includes the date, server name, and directory name. The script also ensures that the output file is not included in the archive.
- Customizable Exclusions: Choose between no exclusions, all common exclusions, or provide a custom list of files and directories to exclude.
- Automatic Exclusion of Output File: The script automatically excludes the tarball it is generating from the archive.
- Default Filename Format: The output file is named using the format
YYYYMMDD_tarup_[servername]_[directory].tar.gz, whereYYYYMMDDis the current date,[servername]is the hostname, and[directory]is the directory being archived. - Flexible Output Options: Specify the output file's path and name if the default format doesn't suit your needs.
-
Clone the Repository:
git clone https://github.com/drhdev/tarup.git
-
Navigate to the Repository Directory:
cd tarup -
Make the Script Executable:
chmod +x tarup.sh
./tarup.sh [OPTIONS]-
-e [none|all|custom]: Specify the exclusion set.none- No exclusions.all- Full set of common exclusions (default).custom- Provide a custom list of exclusions (comma-separated).
-
-o [output_file]: Specify the output tar.gz file's path and name. -
-h,-help: Display the help message.
- If no options are provided, the script uses the
allexclusion set and creates a tarball namedYYYYMMDD_tarup_[servername]_[directory].tar.gzin the current directory.
-
Run with Default Settings (All Exclusions):
./tarup.sh
-
Run with No Exclusions:
./tarup.sh -e none
-
Run with Custom Exclusions:
./tarup.sh -e custom -e "*.log,.cache,.env" -
Specify a Custom Output File:
./tarup.sh -o /path/to/output/file.tar.gz
-
Display Help:
./tarup.sh -h ./tarup.sh -help
Suppose you are in the /home/user/project directory on a server named myserver, and you run the following command:
./tarup.shThe script will create a tarball named 20240820_tarup_myserver_project.tar.gz in the /home/user/project directory, excluding common system files, cached files, and any files listed in the all exclusion set.
This project is licensed under the GPL-3.0 License. See the LICENSE file for more details.
Contributions are welcome! Please submit pull requests or open issues to suggest improvements or report bugs.
This script was developed to provide a simple yet powerful way to create backups of directories while allowing for flexible exclusion of unwanted files.