Backup

file_backup

Back up a file by copying it to .bak.. If SHELLAC_BACKUP_DIR is set, the backup is placed there instead.

Example

file_backup /etc/hosts            # creates /etc/hosts.bak.20240319-153045

Arguments

  • $1 (string): File to back up

Exit codes

  • 0: Success; 1 Source file not found; 2 Missing argument

Output on stdout

  • Path of the backup file

file_restore

Restore a file from its most recent .bak.* backup. If SHELLAC_BACKUP_DIR is set, looks there for the backup.

Example

file_restore /etc/hosts    # restores from /etc/hosts.bak.<latest>

Arguments

  • $1 (string): Original file path

Exit codes

  • 0: Restored; 1 No backup found; 2 Missing argument

file_is_backed_up

Return 0 if a backup (.bak.*) exists for the given file.

Arguments

  • $1 (string): File path to check

Exit codes

  • 0: Backup exists; 1 No backup; 2 Missing argument