bbprofile Backup Browser Profile

Here is a place for your projects which are not officially supported by the Porteus Team. For example: your own kernel patched with extra features; desktops not included in the standard ISO like Gnome; base modules that are different than the standard ISO, etc...
Post Reply
User avatar
M. Eerie
Shogun
Shogun
Posts: 216
Joined: 31 Aug 2017, 21:18
Distribution: APorteus BUDGIE x64

bbprofile Backup Browser Profile

Post#1 by M. Eerie » 01 May 2020, 15:18

Starting from this idea I've been refining some code and came to this:

Invoke as:

Code: Select all

$ bbprofile <browser>

Code: Select all

#!/bin/bash
#
# bbprofile: Saves your browser profile into a .xzm module in your Desktop directory
# 
#

usage() {
  echo "Usage: `basename $0` <browser>" >&2
  echo 'Supported Browsers: firefox | opera | vilvaldi | chromium | chrome'
  exit 1
}

# (LOCATION OF BROWSER PROFILES AS OF 2020-05)
profile=
case $1  in
    firefox)
    profile=$HOME/.mozilla 
    ;;
    opera|vivaldi|chromium)
    profile=$HOME/.config/$1
    ;;
    chrome)
    profile=$HOME/.config/google-chrome
    ;;

    *) usage ;;
esac

target=`mktemp -d` && mkdir -p $target$profile || exit
excludeopts=
read -p "Exclude caches, backups, storage and reports (crashes,dumps...) ? [yY / ] "
echo
[[ $REPLY =~ ^[Yy]$ ]] && excludeopts="--exclude=Cache --exclude *backups --exclude *storage --exclude *rash* --exclude *dumps --exclude *report"

rsync -av --delete-before --exclude=lock $excludeopts $profile/ $target$profile
profile=009-profile-$1-$(date +%Y%m%d-%H%M).xzm
mksquashfs $target/home $target/$profile -b 1M -comp xz -Xbcj x86 -noappend -keep-as-directory
mv $target/$profile $(xdg-user-dir DESKTOP)
rsync -a --delete `mktemp -d`/ $target

echo
echo "Your profile module is saved in" $(xdg-user-dir DESKTOP)/$profile
read -p "Would you like to copy it into your $PORTDIR/modules folder? [yY / ] "
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
 then
 echo "Module not copied"
else
 cp -a $(xdg-user-dir DESKTOP)/$profile $PORTDIR/modules && echo "Module copied and ready to be activated at next boot"
fi

exit

Let me know if it works for you :)

Cheers!
Last edited by M. Eerie on 15 May 2020, 15:51, edited 10 times in total.

User avatar
Ed_P
Moderator
Moderator
Posts: 5644
Joined: 06 Feb 2013, 22:12
Distribution: 4.0 & 5.0rc2 Cinnamon 64 ISOs
Location: Western NY, USA

bbprofile Backup Browser Profile

Post#2 by Ed_P » 01 May 2020, 17:33

Interesting.

Ran it for firefox, it ran, appears to have used the correct browser folder, briefly displayed a window in upper right corner of desktop, no idea where the .xzm file is, or how big it is. It's not in /tmp or /home/guest. :(

-update-

Once browser closed found the .xzm file. File 15.5MB. When I backup my Firefox browser's files my module is less than 9MB. But I only backup the files that I have changed or added.
Ed

User avatar
M. Eerie
Shogun
Shogun
Posts: 216
Joined: 31 Aug 2017, 21:18
Distribution: APorteus BUDGIE x64

bbprofile Backup Browser Profile

Post#3 by M. Eerie » 01 May 2020, 18:56

Thanks for the feedback :)
Ed_P wrote:
01 May 2020, 17:33
briefly displayed a window in upper right corner of desktop
Script updated. Notification should be fixed now. Try to add -t 0 at the very end of the script. (I've changed first line too).

By default, the module is saved into your desktop, letting the user choose whether to move it onto the activation chain or not.

As for the size, I'm just backing up the whole unfiltered profile to keep things simple.

Cheers!

User avatar
M. Eerie
Shogun
Shogun
Posts: 216
Joined: 31 Aug 2017, 21:18
Distribution: APorteus BUDGIE x64

bbprofile Backup Browser Profile

Post#4 by M. Eerie » 01 May 2020, 19:49

Hmmmmm. Seems like cleanup part is not working as expected... Will check and came back when fixed.

Cheers!

User avatar
Ed_P
Moderator
Moderator
Posts: 5644
Joined: 06 Feb 2013, 22:12
Distribution: 4.0 & 5.0rc2 Cinnamon 64 ISOs
Location: Western NY, USA

bbprofile Backup Browser Profile

Post#5 by Ed_P » 01 May 2020, 20:37

I had tried -t 50000 also with same results.

Suggestions:

Code: Select all

# bbprofile: Saves your browser profile into a .xzm module on your desktop
  or
# bbprofile: Saves your browser profile into a .xzm module in your Desktop directory
  rather than
# bbprofile: Saves your browser profile into a .xzm module in your desktop

echo 'Copy the module into your /MODULES folder' && read
  rather than
notify-send 'Copy this module into your BASE/MODULES @ $PORTDIR ' $(xdg-user-dir DESKTOP)/$profile -i face-smile -t 0
Also FYI

Code: Select all

guest@porteus:/mnt/sda6/porteus4.0/Guest$ echo $PORTDIR
/mnt/isoloop/porteus
guest@porteus:/mnt/sda6/porteus4.0/Guest$ echo $profile

guest@porteus:/mnt/sda6/porteus4.0/Guest$ 
Added in 18 minutes 3 seconds:
FWIW What I'm backing up.

Code: Select all

guest@porteus:~$ ls -igh /tmp/mod/home/guest/.mozilla/
total 0
29955 drwxr-xr-x 3 users 120 May  1 12:40 firefox/
29954 lrwxrwxrwx 1 users  27 May 15  2018 plugins -> /usr/lib64/mozilla/plugins//
guest@porteus:~$ ls -igh /tmp/mod/home/guest/.mozilla/firefox
total 12K
29959 drwxr-xr-x 4 users 380 May  1 16:41 dxsqumip.default/
29956 -rw-r--r-- 1 users  54 Mar  8 23:36 installs.ini
29957 -rw-r--r-- 1 users 104 Mar  1  2018 profiles\ (52.9.0).ini
29958 -rw-r--r-- 1 users 175 Mar  8 23:36 profiles.ini
guest@porteus:~$ ls -igh /tmp/mod/home/guest/.mozilla/firefox/dxs*
total 5.9M
29960 -rw------- 1 users  969 Mar 12 16:22 addonStartup.json.lz4
29961 -rw------- 1 users 4.3K Apr 28 01:33 addons.json
29978 drwxr-xr-x 4 users   80 May  1 16:41 browser-extension-data/
29962 -rw-r--r-- 1 users 224K Apr 28 17:47 content-prefs.sqlite
29963 -rw-r--r-- 1 users 1.5M Apr 30 18:18 cookies.sqlite
29974 drwxr-xr-x 2 users  100 May  1 16:41 extensions/
29984 -rw------- 1 users  31K Apr 28 01:35 extensions.json
29964 -rw-r--r-- 1 users 5.0M Apr 28 23:22 favicons.sqlite
29965 -rw-r--r-- 1 users 288K Apr 30 18:17 formhistory.sqlite
29966 -rw-r--r-- 1 users  16K Mar 14 01:59 key3.db
29967 -rw-r--r-- 1 users 288K Mar 14 01:59 key4.db
29968 -rw------- 1 users 2.7K Apr 28 19:20 logins.json
29969 -rw-r--r-- 1 users  96K Apr 23 02:50 permissions.sqlite
29970 -rw-r--r-- 1 users 5.0M Apr 30 18:18 places.sqlite
29971 -rw-r--r-- 1 users  24K Apr 30 18:18 prefs.js
29972 -rw------- 1 users  14K Apr 30 18:16 search.json.mozlz4
29973 -rw------- 1 users 2.8K Apr 30 18:18 xulstore.json
Added in 3 hours 25 minutes 6 seconds:
~40KB

Code: Select all

rsync -av --delete-before --exclude=Cache --exclude=lock --exclude  Crash* --exclude *backups ==exclude crashes ==exclude *dumps ==exclude *reporting  $profile/ $target$profile
Ed

User avatar
M. Eerie
Shogun
Shogun
Posts: 216
Joined: 31 Aug 2017, 21:18
Distribution: APorteus BUDGIE x64

bbprofile Backup Browser Profile

Post#6 by M. Eerie » 02 May 2020, 07:13

Ed_P wrote:
02 May 2020, 00:20
bbprofile: Saves your browser profile into a .xzm module in your Desktop directory
Modified, thanks!
Ed_P wrote:
02 May 2020, 00:20
guest@porteus:/mnt/sda6/porteus4.0/Guest$ echo $profile
Keep in mind that the $profile variable is only used in the script execution scope, (i.e. not in your shell terminal session).

Rechecked the cleanup and is working well. At home, I was missing a '/' in my script. The only leftovers are just two empty /tmp/.tmp.* dirs.

To be honest, I'm not backing up the full profile because I'm not checking whether the browser is running or not. So, the script assumes it's open and excludes locked files. But then:
Ed_P wrote:
02 May 2020, 00:20
--exclude *backups --exclude crashes --exclude *dumps --exclude *reporting
This one is useful if order to reduce the module size. Using it now :)
(Will include it as an option)
Done. Also excluding storage which results in a quite barebones profile module.

Cheers!
Last edited by M. Eerie on 02 May 2020, 09:26, edited 1 time in total.

User avatar
M. Eerie
Shogun
Shogun
Posts: 216
Joined: 31 Aug 2017, 21:18
Distribution: APorteus BUDGIE x64

bbprofile Backup Browser Profile

Post#7 by M. Eerie » 02 May 2020, 07:28

Ed_P wrote:
02 May 2020, 00:20
I had tried -t 50000 also with same results.
Have you tried with -t 0 ??? (show notification until clicked). Also, do you have notifications activated?
Ed_P wrote:
02 May 2020, 00:20
echo 'Copy the module into your /MODULES folder' && read
I was starting the script through a .desktop launcher in my ~/.local/share/applications folder. So it was fairly easy to create the module with two clicks.

Given the fact that it now uses a parameter and the script has to be started from the cli, it seems logical to change the notification to your suggestion. Thanks again:)

Cheers!

User avatar
Ed_P
Moderator
Moderator
Posts: 5644
Joined: 06 Feb 2013, 22:12
Distribution: 4.0 & 5.0rc2 Cinnamon 64 ISOs
Location: Western NY, USA

bbprofile Backup Browser Profile

Post#8 by Ed_P » 02 May 2020, 14:24

M. Eerie wrote:
02 May 2020, 07:28
Ed_P wrote:
02 May 2020, 00:20
I had tried -t 50000 also with same results.
Have you tried with -t 0 ??? (show notification until clicked). Also, do you have notifications activated?
Yes. And -t 20000 but the window shows for about 2 seconds and disappears regardless.

Newest test.

Code: Select all

guest@porteus:~$ ./bbprofile.sh
guest@porteus:~$ 
Nothing!! Not even an error msg.

If run by dbl clicking on it via a GUI file manager there will be no display output when it finishes without a "read" at the end.
Ed

User avatar
M. Eerie
Shogun
Shogun
Posts: 216
Joined: 31 Aug 2017, 21:18
Distribution: APorteus BUDGIE x64

bbprofile Backup Browser Profile

Post#9 by M. Eerie » 02 May 2020, 16:21

Ed_P wrote:
02 May 2020, 14:24
If run by dbl clicking
Remember it needs a parameter to run...

Code: Select all

guest@porteus:~$ ./bbprofile.sh 
Usage: bbprofile.sh <browser>
Supported Browsers: firefox | opera | vilvaldi | chromium | chrome
guest@porteus:~$ 
Also forget about notify-send method, the script was updated following your suggestions.

I've copy-pasted what is above and it is working:
I'm using firefox as well, so I don't know how the exclusion list would affect to other browsers.

Cheers!

User avatar
Ed_P
Moderator
Moderator
Posts: 5644
Joined: 06 Feb 2013, 22:12
Distribution: 4.0 & 5.0rc2 Cinnamon 64 ISOs
Location: Western NY, USA

bbprofile Backup Browser Profile

Post#10 by Ed_P » 02 May 2020, 16:24

Progress.

Code: Select all

guest@porteus:~$ ./bbprofile.sh firefox
Exclude caches, backups, storage and reports (crashes,dumps...) ? [yY / ] y

building file list ... done
./
plugins -> /usr/lib64/mozilla/plugins/
extensions/
 :
 :
 :
Number of gids 1
	users (100)
Copy the module into your /MODULES folder? [yY / ] y

cp: cannot create regular file '/mnt/isoloop/porteus/modules/009-profile-firefox-20200502-1213.xzm': Read-only file system
guest@porteus:~$
 

Cmdline:  quiet BOOT_IMAGE=(loop)/boot/syslinux/vmlinuz from=/ISOs/Porteus-CINNAMON-v4.0-x86_64.iso volume=33 reboot=cold extramod=/porteus4.0/Modules;/porteus4.0/modsavedat noload=save.dat;cinnamon 
And the new module is 9.1 GB. :Yahoo!:

Haven't tested it with Always Fresh yet to see if it works.

Added in 3 minutes 24 seconds:
M. Eerie wrote:
02 May 2020, 16:21
Remember it needs a parameter to run...

Code: Select all

guest@porteus:~$ ./bbprofile.sh 
Usage: bbprofile.sh <browser>
Supported Browsers: firefox | opera | vilvaldi | chromium | chrome
guest@porteus:~$ 
Yes it does and if it doesn't have one it doesn't display what you're showing.
Ed

User avatar
M. Eerie
Shogun
Shogun
Posts: 216
Joined: 31 Aug 2017, 21:18
Distribution: APorteus BUDGIE x64

bbprofile Backup Browser Profile

Post#11 by M. Eerie » 02 May 2020, 16:46

Ed_P wrote:
02 May 2020, 16:28
it doesn't display what you're showing
:hmmm: That's weird. Will investigate.
Ed_P wrote:
02 May 2020, 16:28
Read-only file system
guest@porteus:~$
That's ok... Writing to ISO not implemented :good:

Cheers!

User avatar
Ed_P
Moderator
Moderator
Posts: 5644
Joined: 06 Feb 2013, 22:12
Distribution: 4.0 & 5.0rc2 Cinnamon 64 ISOs
Location: Western NY, USA

bbprofile Backup Browser Profile

Post#12 by Ed_P » 02 May 2020, 18:39

M. Eerie wrote:
02 May 2020, 16:46
Ed_P wrote:
02 May 2020, 16:28
it doesn't display what you're showing
:hmmm: That's weird. Will investigate.
An interesting solution, insure there is a space/blank on line 6. :o :happy62:
M. Eerie wrote:
02 May 2020, 16:46
That's ok... Writing to ISO not implemented :good:
Cheers!
That's to be expected. If the $PORTDIR/modules folder doesn't exist write to a cmdline extramod= cheatcode folder or a non-/mnt/isoloop folder in the /var/log/porteus-livedbg file.
Ed

User avatar
M. Eerie
Shogun
Shogun
Posts: 216
Joined: 31 Aug 2017, 21:18
Distribution: APorteus BUDGIE x64

bbprofile Backup Browser Profile

Post#13 by M. Eerie » 02 May 2020, 23:23

@Ed
It is working for me both in Porteus (MATE) and Nemesis.

See here

Cheers!

User avatar
Ed_P
Moderator
Moderator
Posts: 5644
Joined: 06 Feb 2013, 22:12
Distribution: 4.0 & 5.0rc2 Cinnamon 64 ISOs
Location: Western NY, USA

bbprofile Backup Browser Profile

Post#14 by Ed_P » 03 May 2020, 02:30

Interesting. When I copied it before I highlighted the text and pasted it into the file. This time I tried your approach and clicked on the SELECT ALL link at the top and pasted it into the file and it works. :o

I don't move it around as much as you do, I simply run it from my /home/guest/ folder. As for the Copy prompt at the end I think it should show exactly where it would move the file rather than the generic /MODULES folder. And when the copy fails the user shouldn't have to wonder where the module is until they close their full screen browser window. Maybe this would help?

Code: Select all

read -p "Copy the /home/$whoami/guest/Desktop/ module into your /MODULES folder? [yY / ] " 

Code: Select all

guest@porteus:~$ ./bbprofile.sh
Usage: bbprofile.sh <browser>
Supported Browsers: firefox | opera | vilvaldi | chromium | chrome
guest@porteus:~$ ./bbprofile.sh firefox
Exclude caches, backups, storage and reports (crashes,dumps...) ? [yY / ] y

building file list ... done
./
plugins -> /usr/lib64/mozilla/plugins/
extensions/
firefox/
  :
  :
  :
Number of gids 1
	users (100)
Copy the module into your /MODULES folder? [yY / ] y

cp: cannot create regular file '/mnt/isoloop/porteus/modules/009-profile-firefox-20200502-2206.xzm': Read-only file system
guest@porteus:~$ 
A neat script and great for moving customized browsers between systems. :happy62: :good:

Added in 17 minutes 35 seconds:
:hmmm: MODULES=`cat /var/log/porteus-livedbg | grep odules/$1`

But if the booted system has the browser module why would it need this profile module? :o A way to save browser changes made on a read only system.

Added in 3 minutes 58 seconds:
A bigger question is how did you make the video? A cellphone?

Added in 29 minutes 5 seconds:
-update-

It works. :happy62:

I just tried the bbprofile module in a test system and firefox had all my bookmarks and Add-ons. :Yahoo!:
Ed

User avatar
M. Eerie
Shogun
Shogun
Posts: 216
Joined: 31 Aug 2017, 21:18
Distribution: APorteus BUDGIE x64

bbprofile Backup Browser Profile

Post#15 by M. Eerie » 03 May 2020, 11:25

Ed_P wrote:
03 May 2020, 03:20
When I copied it before I highlighted the text and pasted it into the file
I've seen some strange chars in your inputs (marked in red) that made me suspect -->
Ed_P wrote:
02 May 2020, 00:20
rsync -av --delete-before --exclude=Cache --exclude=lock --exclude Crash* --exclude *backups ==exclude crashes ==exclude *dumps ==exclude *reporting $profile/ $target$profile
:roll:
Ed_P wrote:
03 May 2020, 03:20
As for the Copy prompt at the end I think it should show exactly where...
Ok, fixing it.

Type this at terminal prompt:

Code: Select all

$ env | grep PORTDIR
$ env | grep guest

$ echo $HOME
$ echo $HOME/Desktop
$ echo $(xdg-user-dir DESKTOP) --> mine is /home/guest/Escritorio
$ echo $(xdg-user-dir PICTURES) --> mine is /home/guest/Imágenes
$ echo $(xdg-user-dir DOCUMENTS) --> mine is /home/guest/Documentos
...
...
So $(xdg-user-dir <userdir>) is locale agnostic and already contains $HOME (/home/guest in our case)

Ed_P wrote:
03 May 2020, 03:20
A way to save browser changes made on a read only system
Yes, that's what I use it for. Also it helps me sync profiles between systems. At the end, "the cloud" is someone else's disk... ;)

Glad it works for you :)
Ed_P wrote:
03 May 2020, 03:20
A bigger question is how did you make the video? A cellphone?
This one goes to @ncmprhnsbl
It would be great to use it elsewhere because it helps so much showing howto's

Peek it's bundled here

Cheers!

Post Reply