I am using neo backup often i run into storage issues so i am wondering if there is a possibility of backing data with git, root, Termux, Tasker .

Edit: solved some issues

  • storage issue was fixed by not enabling unnecessary backup options. It created massive difference for most applications, eg anki was over 1 GB, now its 9 KB.
  • Some application’s backups were not working( After restoring applications were crashing), for them, rather than backing up whole data, we can copy relevant data. Eg for element, we can backup by

cp /data/data/im.vector.app/shared_prefs/im.vector.app_preferences.xml %ConfigBackupLocation/element # you need root for this

  • confusedpuppy@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    2
    ·
    6 hours ago

    I don’t have root access on my phone but I still copy backups of my media and apps that export data to accessible files.

    I keep my process very simple using Termux with rsync openssh and termux-services packages.

    I created a folder dedicated on my for syncing between phone to computer called sync but you can change this for your needs.

    From a fresh Termux install, the setup should look something like the following:

    # Update package list and packages
    pkg update && pkg upgrade
    # Install required packages
    pkg install rsync openssh termux-services
    # Setup Termux's access to your phone's files
    termux-setup-storage
    # Make the required folder
    mkdir ~/storage/shared/sync/
    cd ~/storage/shared/sync/
    # Automatically start your SSH server when you open Termux
    sv-enable sshd
    
    • Get your phone’s username:
    ~ $ whoami
    u0_a205
    
    • Optional: Setup a password with the command passwd (I can’t remember if this step is important)

    A quick note: Termux on android has a file system quite different than a computer so file and directory names can get quite long. The pwd command would show /data/data/com.termux/files/home/storage/shared/sync for my sync folder.

    This can be made simpler by using the realpath command. realpath /data/data/com.termux/files/home/storage/shared/sync then shows /storage/emulated/0/sync as a result. If you’re using CLI, this may make your commands easier to read.

    Now you can start to build your rsync command to transfer your files. When setting up an rsync command, ALWAYS use the --dry-run- option. This performs a “transfer” without any files being moved.

    • From my computer (data transfer direction: Phone -> Computer):
    rsync --dry-run --archive --verbose --human-readable --partial --progress --compress -e 'ssh -p 8022' u0_a205@192.168.40.210:/storage/emulated/0/sync/ /home/computer_username/backup/
    
    • From my phone (data transfer direction: Phone -> Computer):
    rsync --dry-run --archive --verbose --human-readable --partial --progress --compress /storage/emulated/0/sync/ computer_username@192.168.40.205:/home/computer_username/backup/
    

    Explanation:

    • --archive preserves several file attributes
    • --verbose --human-readable --partial --progress creates a readable output to see what is happening
    • --compress compresses the data during the actual transfer (good for over a network)
    • -e 'ssh -p 8022' SSH on termux runs on port 8022
    • u0_a205@192.168.40.210:/storage/emulated/0/sync/ and computer_username@192.168.40.205:/home/computer_username/backup/ are how rsync identifies remote folders. Basic format is <username>@<remote IP address>:/path/to/folder/
    • /home/computer_username/backup/ and /storage/emulated/0/sync/ are the local folders, relative to what machine the rsync command is being run from.

    In order to reverse the direction of a command relative to the machine you are running on, simple swap the remote folder and local folder in the command. Example: From only my computer:

    # Direction: Phone -> Computer
    rsync --dry-run --archive --verbose --human-readable --partial --progress --compress -e 'ssh -p 8022' u0_a205@192.168.40.210:/storage/emulated/0/sync/ /home/computer_username/backup/
    
    # Direction: Computer -> Phone
    rsync --dry-run --archive --verbose --human-readable --partial --progress --compress -e 'ssh -p 8022' /home/computer_username/backup/ u0_a205@192.168.40.210:/storage/emulated/0/sync/
    

    In order to actually transfer files, remove the --dry-run option from the previous rsync commands. The output in your terminal will show additional information regarding transfer status.

    Additionally, you can also add the --delete option to the rsync command, this will “deduplicate” files, meaning the source folder will force the destination folder match, file by file. That means deleting any file in the destination folder that does not match the source folder list of files.

    A command WITHOUT --dry-run and WITH --delete would look like the following (CAUTION: THIS CAN DELETE FILES IF UNTEST):

    rsync --delete --archive --verbose --human-readable --partial --progress --compress -e 'ssh -p 8022' u0_a205@192.168.40.210:/storage/emulated/0/sync/ /home/computer_username/backup/
    
    

    I personally manually transfer my backups into an encrypted external drive which I manually decrypt. /u/emhl@feddit.org has a suggestion for automated encrypted backups if that’s more to your needs.