Created
June 20, 2022 02:08
-
-
Save Steffo99/638c8192b4ba34116e7e0aee21fb536f to your computer and use it in GitHub Desktop.
A simple archival script using fish.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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