Jump to content

Command Crate ¿about?

Create and verify compressed backup with XZ (Bash)

cd "${BACKUP_DESTINATION}" && export XZ_DEFAULTS="-9 -T 0" && tar cJf "${BACKUP_FILENAME}.tar.xz" "$TARGET_PATH" 2>/dev/null && tar -tf "${BACKUP_FILENAME}.tar.xz" 2>/dev/null && sha256sum "${BACKUP_FILENAME}.tar.xz" > "${BACKUP_FILENAME}.tar.xz.sha256" && chown -R ${OWNER_USERNAME}:${OWNER_USERNAME} "${BACKUP_DESTINATION}/${BACKUP_FILENAME}.tar.xz"

Performs a series of operations in sequence: navigates to the backup destination, sets compression options (XZ_DEFAULTS for max compression and multi-threading), creates a .tar.xz archive, verifies it, generates a SHA256 checksum, and sets ownership. Each step is dependent on the previous one (using &&), so if any operation fails, the process stops immediately.

backup management [kb:209]