Skip to content

Instantly share code, notes, and snippets.

@Steffo99
Created June 20, 2022 02:08
Show Gist options
  • Save Steffo99/638c8192b4ba34116e7e0aee21fb536f to your computer and use it in GitHub Desktop.
Save Steffo99/638c8192b4ba34116e7e0aee21fb536f to your computer and use it in GitHub Desktop.
A simple archival script using fish.
#!/usr/bin/fish
echo_progress "Backing up (almost) everything..."
echo
for project in (find * -mindepth 0 -maxdepth 0 -type d)
# We're not ready to backup plexarr yet.
if test "$project" = "plexarr"
continue
end
set source "./$project"
set directory "/backups/$project"
set destination "$directory/"(date +'%Y-%m-%d__%H-%m')".tar.gz"
set size (du --summarize --bytes "$source" | cut -f 1)
set humansize (du --summarize --human-readable "$source" | cut -f 1)
echo_progress "Archiving "
echo_highlight "$project"
echo_progress " into "
echo_highlight "$destination"
echo_progress " ($humansize)..."
echo
mkdir --parents "$directory"
tar -cf - "$source" | pv --progress --eta --rate --size "$size" | gzip --to-stdout > "$destination"
end
echo_progress "Backup complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment