[WIP] Fix rsync hanging issue by adding progress output#37
Merged
Conversation
…_usb.sh Agent-Logs-Url: https://github.com/djeada/Bash-Scripts/sessions/eece4f1c-b23f-4f34-ab9f-c7738c7d3cc2 Co-authored-by: djeada <37275728+djeada@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--info=progress2torsynccall inbackup_mode()--excludeentries (storage/,thumbnails/,datareporting/,healthreport/,storage.sqlite) tobackup_mode()rsyncforloop inbackup_mode()--info=progress2torsynccall inrestore_mode()whileloop inrestore_mode()Original prompt
Problem
When running
./src/firefox_profile_usb.sh backup, the script appears to hang with no output for several minutes whilersynccopies a large Firefox profile (e.g.default-release) to a USB drive. The user has no way to tell if the script is working or frozen. The user pressed Ctrl+C after 6 minutes, which killedrsyncwith exit code 20, and theERRtrap then reported a misleading "Script failed" error.Two distinct issues:
storage/,thumbnails/,datareporting/,healthreport/,storage.sqlite) are not excluded, inflating transfer time significantly.File to change
src/firefox_profile_usb.shRequired changes
1. Add
--info=progress2to bothrsynccallsIn
backup_mode()(around line 449), replace:with:
In
restore_mode()(around line 598), replace:with:
--info=progress2prints a single updating line showing bytes transferred, percentage, and transfer rate. It works even when stdout is not a tty (unlike--progress), and doesn't flood logs.2. Add more
--excludeentries tobackup_mode()rsync callAppend these excludes to the existing list (after
--exclude='minidumps/', before the source path):Rationale:
storage/— IndexedDB and localStorage; can be hundreds of MB, fully regenerated by Firefox on next run.thumbnails/— tab thumbnails; regenerated automatically.datareporting/andhealthreport/— telemetry data; not needed for restore.storage.sqlite— stores quota info forstorage/; regenerated withstorage/.These directories are not needed for a functional restore (bookmarks, history, passwords, extensions all live elsewhere) and can save 50–500 MB per profile.
3. Update the
usage()function comment to mention that large profiles may take several minutesNo change needed to
usage()itself, but add a brief log message inbackup_mode()just before the rsync loop starts (afterdiscover_profilesis called and before theforloop):log "Copying profiles to USB (this may take several minutes for large profiles)..."And similarly in
restore_mode()just before thewhileloop:log "Restoring profiles from USB (this may take several minutes for large profiles)..."Summary of all changes
backup_mode()rsync call--info=progress2flagbackup_mode()rsync excludesstorage/,thumbnails/,datareporting/,healthreport/,storage.sqlitebackup_mode()before looprestore_mode()rsync call--info=progress2flagrestore_mode()before loopThe following is the prior conversation context from the user's chat exploration (may be truncated):
User: it hangs: chmod u+x src/* && ./src/firefox_profile_usb.sh backup
[09:41:16] Starting Firefox backup...
[09:41:16] Firefox profile directory: /home/adam/.mozilla/firefox
[09:41:16] Checking whether Firefox is fully closed...
[09:41:16] Firefox is closed.
[09:41:16] One USB drive found. Auto-selecting: /media/adam/D28D-C3E1
[09:41:16] Discovered 2 Firefox profile(s).
[09:41:16] Profile 'default': no saved-password store detected
[09:41:16] Profile 'default': integrity checks passed.
[09:41:17] Backing up profile 'default' from /home/adam/.mozilla/firefox/5cz2vuis.default
[09:41:17] Profile 'default': no saved-password store detected
[09:41:17] Profile 'default': integrity checks passed.
[09:41:17] Profile 'default-release': password store present, logins count = 34
[09:41:18] WARNING: Skipping non-critical SQLite file that failed quick_check: /home/adam/.mozilla/firefox/5fqo5qcu.default-release/suggest.sqlite
[09:41:18] Profile 'default-release': integrity checks passed.
[09:41:18] Backing up profile 'default-release' from /home/adam/.mozilla/firefox/5fqo5qcu.default-release
^Crsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(716) [sender=3.2.7]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at io.c(519) [generator=3.2.7]
[09:47:35] ERROR: Script failed near line 449 (exit 20)
Assistant: The script isn't actually hanging — it's copying a large Firefox profile to a USB drive, and that's slow. You interrupted it (Ctrl+C) after ~6 minutes while
rsyncwas transferring thedefault-releaseprofile (the one with 34 saved passwords and likely gigabytes of browser data includingcache2/, history, etc.).Here's...
This pull request was created from Copilot chat.