• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
UBports Robot Logo UBports Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Migrate data from device to device

Scheduled Pinned Locked Moved Support
34 Posts 12 Posters 9.3k Views 7 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      kwah
      last edited by 17 Sept 2018, 21:51

      As a user, which has got a new UBports device, I would like to migrate all data from my currently used UBports device to the new one.

      What can I do? Is there "simple" backup / restore howto addressing the user story above?

      Quick search in interwebs and this forum returned a big number of discussed topics mainly on synchronizing various data categories to / from PC, but I could not find any consistent story about migration from device to device. If you know one - please comment.

      1 Reply Last reply Reply Quote 0
      • G Offline
        guru
        last edited by 18 Sept 2018, 06:40

        I have not done this (and perhaps would not do that), because IMHO it's better to move certain app data selectively. How to move, for example contacts, is written "in stone" here: https://gurucubano.gitbooks.io/bq-aquaris-e-4-5-ubuntu-phone/content/en/chapter9.html

        1 Reply Last reply Reply Quote 0
        • F Offline
          flohack
          last edited by 18 Sept 2018, 08:44

          A complete backup should work as follows:

          • Connect your device with USB and have adb ready
          • Issue adb reboot recovery
          • Create a local directory for the backup and cd into it
          • Issue adb pull /data/system-data and adb pull /data/user-data
          • This will take a while each. If everything goes well you should have both folders in your backup directory

          A restore is the other way round:

          • Connect your device with USB and have adb ready
          • Issue adb reboot recovery
          • cd into your backup folder
          • Issue adb push system-data /data/system-data and adb push user-data /data/user-data

          Note You have to be very careful with the adb paths. Sometimes it just throws everything into ., sometimes it follows into the sub directory. The correct how-to for this paths is not clear to me now πŸ˜‰

          My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

          K 1 Reply Last reply 15 Jun 2019, 21:54 Reply Quote 2
          • I Offline
            Ingo
            last edited by 30 Jan 2019, 19:47

            Did anyone else encounter this:

            $ adb pull /data/system-data
            adb: error: failed to copy '/data/system-data/etc/writable/localtime' to './system-data/etc/writable/localtime': remote No such file or directory
            
            L 1 Reply Last reply 30 Jan 2019, 20:03 Reply Quote 0
            • L Offline
              Luksus @Ingo
              last edited by 30 Jan 2019, 20:03

              @ingo yes, I had the same kind of issue on my FP2 and gave up...

              Devices: BQ e4.5, Fairphone 2, Fairphone 3, Lenovo X605F, Pinephone, Moto Z2 Force, OnePlus5T

              1 Reply Last reply Reply Quote 1
              • I Offline
                Ingo
                last edited by 31 Jan 2019, 08:35

                Sounds a bit like a dangling link, similar to what is described here: https://bugs.launchpad.net/snappy/+bug/1650688

                R 1 Reply Last reply 18 Feb 2019, 15:13 Reply Quote 0
                • R Offline
                  Rondarius @Ingo
                  last edited by 18 Feb 2019, 15:13

                  You have to create the directory of system-data and user-data on the pc and put the files that you pulled from the device into the directory. I did not do this until after I had pulled from both system-data and user-data, I copied all of the files/folders that was pulled in both directories.

                  4 Google Pixel 3A
                  1 Google Nexus 6P
                  2 Google Nexus 5
                  2 Pinephones
                  2 Sony Xperia X

                  R I 2 Replies Last reply 18 Feb 2019, 16:56 Reply Quote 0
                  • R Offline
                    Rondarius @Rondarius
                    last edited by 18 Feb 2019, 16:56

                    HMMMM I bricked my phone. I am back shortly after doing a reinstall of my phone and I am doing a total wipe of the storage.

                    4 Google Pixel 3A
                    1 Google Nexus 6P
                    2 Google Nexus 5
                    2 Pinephones
                    2 Sony Xperia X

                    1 Reply Last reply Reply Quote 0
                    • I Offline
                      Ingo @Rondarius
                      last edited by 18 Feb 2019, 17:25

                      @Rondarius said in Migrate data from device to device:

                      You have to create the directory of system-data and user-data on the pc and put the files that you pulled from the device into the directory

                      Yeah, but pulling the files from the device to the PC is the thing that doesn't work.

                      R 1 Reply Last reply 18 Feb 2019, 18:21 Reply Quote 0
                      • R Offline
                        Rondarius @Ingo
                        last edited by 18 Feb 2019, 18:21

                        @Ingo Hmm I didn't get any errors while pulling the files to the pc, I'm on a Nexus 5.

                        4 Google Pixel 3A
                        1 Google Nexus 6P
                        2 Google Nexus 5
                        2 Pinephones
                        2 Sony Xperia X

                        R 1 Reply Last reply 18 Feb 2019, 18:23 Reply Quote 0
                        • R Offline
                          Rondarius @Rondarius
                          last edited by 18 Feb 2019, 18:23

                          Development branch.

                          4 Google Pixel 3A
                          1 Google Nexus 6P
                          2 Google Nexus 5
                          2 Pinephones
                          2 Sony Xperia X

                          1 Reply Last reply Reply Quote 0
                          • R Offline
                            Rondarius
                            last edited by 18 Feb 2019, 18:59

                            I did a new backup on my phone and tried to migrate to another Nexus 5. The wifi nor the mobile network works, notes, the clock app, the calculator an gallery does not work either. But all my contacts and messages has been imported:upside-down_face:. I have not tried with other apps.

                            4 Google Pixel 3A
                            1 Google Nexus 6P
                            2 Google Nexus 5
                            2 Pinephones
                            2 Sony Xperia X

                            1 Reply Last reply Reply Quote 0
                            • K Offline
                              kwah @flohack
                              last edited by kwah 15 Jun 2019, 21:54

                              Found this topic again after a while, since screen of my bq 4.5 is not responding to touches anymore.

                              Tried to do backup as explained by @Flohack in Migrate data from device to device. Below are my observations and notes.

                              Sequence adb reboot recovery followed by adb pull /data/system-data have not copied anything, because it errored out:

                              $ adb pull /data/system-data
                              adb: error: failed to copy '/data/system-data/lib/ufw/user6.rules' to './system-data/lib/ufw/user6.rules': remote Permission denied
                              

                              Added adb root to the mix to handle "Permission denied", and after a bit of copying I've got to the next error:

                              $ adb pull /data/system-data
                              adb: error: failed to copy '/data/system-data/var/log/installer/media-info' to './system-data/var/log/installer/media-info': remote No such file or directory
                              

                              Looks like permission errors can be resolved. Why files are missing?

                              After digging a bit (cross-referencing results of broken symlinks in recovery and normal environments, looking into mounted filesystems and layout) I think it is because of "dangling" links pointing to nowhere for the following reasons:

                              • Parts of the file system are not available in the recovery environment, because not mounted, like many click packages
                              • There are broken links in the systems (links that are broken also in normal boot) accumulated through its lifetime due to bad behaviors of install/uninstall/upgrade tools and SW in general

                              All the above leads me to the following:

                              • Looks like adb pull should be run at least in rooted recovery (maybe it should also use -a switch to preserve permissions?)
                              • adb pull cannot handle "dangling" links

                              So in my experience adb pull is not a good tool to make a backup.

                              I would really appreciate, if someone could comment on the above and tip better and working ways to backup data so that it can be restored on the other device.

                              Currently I am looking into the option of creating backup on external sdcard using tar + gzip.

                              1 Reply Last reply Reply Quote 0
                              • K Offline
                                kwah
                                last edited by 16 Jun 2019, 10:51

                                Here is an instruction that worked for me to transfer data from Bq 4.5 to Fairphone 2

                                Required:

                                • SD-card
                                • Both device should have SD-card slot
                                • adb tools

                                Preliminary Steps

                                • Check that your SD-card is accessible on both devices
                                • While device is booted and connected to PC, figure out SD-card info needed for accessing it when device is booted into recovery:
                                  • In adb shell issue mount command
                                  • Note the device that is mounted to /media/phablet/<...>, example in my case
                                    <... -removed>
                                    /dev/mmcblk1p1 on /media/phablet/ubackup type vfat (rw,nosuid,nodev,relatime,uid=32011,gid=32011,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)
                                    
                                    Note that device /dev/mmcblk1p1 is mounted to /media/phablet/ubackup, which is SD card in my case, expect that last part of /media/phablet/ubackup will be different in your case. Make note of the device name (/dev/mmcblk1p1).

                                Backup data to SD card

                                1. If not done before: connect phone to PC while adb is running
                                2. Reboot phone into recovery: adb reboot recovery
                                3. Acquire root: adb root
                                4. Activate shell: adb shell
                                5. In the root shell (command prompt ends with # sign)
                                  5.1 Mount SD card with the following command (note that /dev/mmcblk1p1 above becomes /dev/block/mmcblk1p1) :
                                  mount -t vfat -o flush,utf8 /dev/block/mmcblk1p1 /sdcard
                                  
                                  5.2 Backup system-data and user-data partitions (commands below will also create log files, that can be examined for possible errors) :
                                  tar -czpv -f /sdcard/system-data.tgz /data/system-data/ >/sdcard/system-data.out 2>/sdcard/system-data.err
                                  
                                  tar -czpv -f /sdcard/user-data.tgz /data/user-data/ >/sdcard/user-data.out 2>/sdcard/user-data.err
                                  
                                  5.3 Check created archives. The commands below should not produce any output:
                                  tar -xzv -f /sdcard/system-data.tgz >/dev/null
                                  
                                  tar -xzv -f /sdcard/user-data.tgz >/dev/null
                                  
                                6. Power down your device (example for adb shell) :
                                  shutdown -P now
                                  

                                Restore data from the backup on SD card

                                For me it was repeat of the sequence from the previous section but with the target device connected. The only difference was in the final step.

                                In principle, external card reader device may require different device name in mount command of step 5.1 options. You can check it as indicated in the Preliminary Steps section above.

                                Repeat steps 1. ... 5.1 to make SD card accessible.

                                1. In the root shell (command prompt ends with # sign)
                                  5.1 Mount as in the 5.1 above
                                  5.2 Restore data:
                                  tar -xzv -f /sdcard/system-data.tgz
                                  
                                  tar -xzv -f /sdcard/user-data.tgz
                                  
                                2. Reboot your device
                                1 Reply Last reply Reply Quote 1
                                • F Offline
                                  flohack
                                  last edited by 18 Jun 2019, 19:11

                                  TLDR; In case you get pull errors, leave system data out. You will loose all your settings in system-settings etc but the app data is in user-data and that folder must always be pullable without issues. You might want to delete the contents of .cache before to make it smaller...

                                  My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

                                  K 1 Reply Last reply 18 Jun 2019, 20:05 Reply Quote 0
                                  • K Offline
                                    kwah @flohack
                                    last edited by 18 Jun 2019, 20:05

                                    @Flohack said in Migrate data from device to device:

                                    TLDR; In case you get pull errors, leave system data out. You will loose all your settings in system-settings etc but the app data is in user-data and that folder must always be pullable without issues. You might want to delete the contents of .cache before to make it smaller...

                                    Well, loosing all settings in system-settings etc. looks like a big deal. One needs to reconfigure everything then.

                                    As far as I understand, system data is not and will not be pullable unless the tools are fixed with respect to handling "dangling" symlinks.

                                    Unfortunately, I had issues with user-data as well.

                                    By the way, do you agree that in the original instruction adb root should be added? I don't know which phone you used as a reference to create the instruction, but I have noticed that adb shell on Fairphone 2 has root enabled by default.

                                    Looks like we start to get requirements for user data lint tool / backup prepare tool πŸ˜‰ (maybe something for UT Tweak):

                                    • Cleanup caches (is it safe to remove qmlcache/qml_cache/api_cache and friends?)
                                    • Remove "dangling" sym-links
                                    • ...
                                    1 Reply Last reply Reply Quote 0
                                    • F Offline
                                      flohack
                                      last edited by 20 Jun 2019, 07:33

                                      Hmm I am wondering maybe its your adb version that makes that issue, can you check which one you have? Try adb version...

                                      You cannot remove dangling symlinks, as they are probably used in the live image. I will try again what I did. adb shell should give root on all devices in recovery.

                                      BR Florian

                                      My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

                                      1 Reply Last reply Reply Quote 0
                                      • K Offline
                                        kwah
                                        last edited by 20 Jun 2019, 22:29

                                        I used adb from Ubuntu 19.04 repositories:

                                        $ adb version
                                        Android Debug Bridge version 1.0.39
                                        Version 1:8.1.0+r23-5
                                        Installed as /usr/lib/android-sdk/platform-tools/adb
                                        
                                        $ apt-cache policy adb
                                        adb:
                                          Installed: 1:8.1.0+r23-5
                                          Candidate: 1:8.1.0+r23-5
                                          Version table:
                                         *** 1:8.1.0+r23-5 500
                                                500 http://archive.ubuntu.com/ubuntu disco/universe amd64 Packages
                                                100 /var/lib/dpkg/status
                                        

                                        Concerning root: I had to explicitly request it on Bq 4.5. On FP2 adb shell was with root access enabled by default.

                                        1 Reply Last reply Reply Quote 0
                                        • T Offline
                                          thepeter
                                          last edited by thepeter 23 Jan 2020, 16:27

                                          Consider this my "log" how I've transferred data from phone to phone (worked between two nexus 5 devices) without SD card
                                          I hope it will be helpful for somebody - but I've basically used combination of two methods described before plus some man pages
                                          NOTE: both devices have ubports image installed and are prepared for adb access ()

                                          Source device

                                          After connecting source device on PC commands in terminal as follows:

                                          1. Reboot phone into recovery: adb reboot recovery
                                          2. Acquire root: adb root
                                          3. Activate shell: adb shell (command prompt will change to # sign)
                                          4. Backup system-data (this will also create log files, that can be examined for possible errors) :
                                            tar -czpv -f /system-data.tgz /data/system-data/ >/system-data.out 2>/system-data.err
                                            NOTE: I've just put these files into root directory and it went just fine πŸ˜‰ and pulled just one file into connected computer since adb has much better chance to transfer one big file without errors than many small ones
                                          5. logout from shell to your terminal (Ctrl+D)
                                            NOTE: I am assuming computer is linux with root access etc.
                                            this sub-step can be done before step 3
                                            5.1 go to directory where backup data are to be stored in PC (using cd and mkdir commands)
                                          6. transfer data from phone to PC adb pull /system-data.tgz
                                            6.1 it is good idea to have logs copied too adb pull /system-data.out and adb pull /system-data.err but it is not necessary
                                          7. steps 3. to 6. repeat but with user-data instead of system-data excluding .cache folder
                                            (so commands will look like tar -czpv -f /user-data.tgz /data/user-data/ --exclude='*data/user-data/phablet/.cache*' >/user-data.out 2>/user-data.err, adb pull /user-data.tgzetc.)
                                            NOTE: data which can be transferred by MTP should be moved that way since process of packing can take quite long for user data and may even stop/fail (e.g. not stopping process, just waiting and overheating battery, because all outputs are transferred to log files) if there is not enough space for package

                                          Destination device

                                          1. Reboot phone into recovery: adb reboot recovery
                                          2. Acquire root: adb root
                                          3. Push archived data from PC to phone (root folder) adb push ./system-data.tgz / and adb push ./user-data.tgz /
                                            NOTE: in case of failure pushing both files and then unpacking both in adb shell it is possible to work the process "per partes" so following steps 4. and 5. will be done after each push and removing archive from phone (rm ./system-data.tgz in adb shell and then returning by Ctrl+D to PC shell)
                                          4. Activate shell: adb shell (command prompt will change to # sign)
                                          5. Extract archives tar -xzv -f /system-data.tgz and tar -xzv -f /user-data.tgz
                                          6. Restart phone, unplug, recharge (battery will be probably rather low πŸ˜… ) check data and switch SIM card πŸ˜€

                                          PS:

                                          After finishing and documenting the process, I'we found out that WiFi settings has not been transferred to destination device 😐 those must be somewhere in .cache folder then (I don't really mind, messages, apps, contacts and other settings are quite enough for me)

                                          T 1 Reply Last reply 23 Apr 2023, 09:29 Reply Quote 3
                                          • T Offline
                                            TartanSpartan
                                            last edited by TartanSpartan 21 May 2020, 23:25

                                            This is great information and thank you guys for the guide. It truly helped me migrate from an M10 with a shattered screen (but the touchscreen still works) to a new one with bigger storage. But I'd like to make my own recommendation on top of this. @thepeter recommends to exclude *data/user-data/phablet/.cache*. This makes sense in general (most app cache directories are pretty disposable and will be rebuilt automatically and as necessary on your new device), but I would take an extra (as in, separate from the main archives you compress) .tgz archive of .cache/libertine-container/ (if you have one or even more than one container) as this will copy over all Libertine apps, app icons, dependencies, the container's rootfs etc. It's arguably just as important as user-data.tgz as that one copies the main Ubuntu Touch apps.

                                            Are there any other directories within .cache which people think would be worthy of backing up and migrating, for genuinely useful and essential stuff like the Libertine apps, and so which should be made an exception to the exclusion command criteria?

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post