Install the Android-SDK
To backup your device with data only:
adb backup -all -f d:\nexus5_data_20170412.ab
To backup your device including Data and Apps:
adb backup -all -apk -shared -f d:\nexus5_complete_20170412.ab
Restore the backup
adb restore d:\nexus5_20140101.ab
If your phone is not supported anymore (Nexus 5) you can install a custom rom to have all security related updates on it.
It first the phone must have an unlocked boot loader
Download twrp from: https://twrp.me/devices/lgnexus5.html
I used https://dl.twrp.me/hammerhead/twrp-3.0.2-0-hammerhead.img
Rename twrp-3.0.2-0-hammerhead.img -> recovery.img
Open a terminal and type:
Make sure developer mode is enabled on the phone.
adb reboot bootloader
fastboot flash recovery d:\Nexus5_backup\recovery.img
Make sure to hold directly volumn down + power.
Now select recovery mode and you should see the new recovery image loaded.
Connect a OTG usb adapter and a USB stick (formatted with FAT32).
In TWRP select backup and select OTG as backup destination.
Install custom rom
I use the pure nexus project: http://forum.xda-developers.com/google-nexus-5/development/rom-pure-nexus-substratum-t3477787
To unlock the bootloader switch of the phone.
Then boot into bootloader/fastboot mode by holding volume down + power.
Plug the phone to your computer and make sure it could be found:
If it is found, continue:
Confirm on the phone using the volumn key and power button.
Reboot the phone with:
Now wait till the phone is completely booted again and restore