Try using a terminal screen session. A screen session is a special type of terminal session that won't die if your network connection dies, your local computer is restarted, etc. You can then simply open up the screen session again when your network permits, and continue where you left off.
Installing on Arch:
pacman -S screen
apt install screen
yum install screen
SSH into your remote machine, and run
screen. You are now in a screen session.
Do whatever you need, example:
If your connection to the server dies, simply SSH in again and run:
-x flag. Your terminal session is now resumed like nothing was ever closed. Type exit to close it when done.
Note that screen sessions allow for multiple highly managed instances and has tons of functionality. They are out of scope here though, so wont be covered.