Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years. You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give you a link to get 115 GB for free for two years.
You will see a link in your terminal, which you can paste into your browser. You may be prompted to login to Google. Next give Gdrive allow permissions, then Copy/Paste the code from the page into the terminal. Google drive command is now ready.
Step Two - Backup the boot partition directly to Google Drive
In just two lines of code, you can send the boot partition image directly to Google Drive, on-the-fly.
....and that's it! ..but.. a little explanation helps though right?
"dd" pipes the raw image data of your boot partition into "gzip", which compresses that data, then pipes "|" the compressed result into "drive upload".
Note: Large boot partitions, which is unusual but possible..can take considerable time depending on the speed of your internet connection. The "conv=sparse" option will zero empty space, making the resulting file much smaller compressed than the actual size of the partition; however, in some cases it may be necessary to resize the partition, backup, then resize back to the full available space. Or, you can split the image using the methods described in Step Four.
Step Three - Backup your Linux installation
The below lines of code will backup your "/" root folder and place the backup file on the root of the drive.
If your drive does not have at least 50% free space, you may have to choose an alternate location, include command switches to use higher compression (slower), or add exclusions for large files you don't necessarily need to backup.
cd /sudo tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --one-file-system /
Depending on the size of the backup file, it may be necessary to split it into smaller files (I recommend 2GB files). Files larger than 2GB have a higher likelihood of getting timed out when transferring to Google Drive, and you won't know it unless you are regularly creating and examining logs of each step using " >> Logfile.txt", stdout after each command.
If the file is regularly failing to transfer in full, due to the size, then you should split it...otherwise transfer the file as a whole using...
Once you are familiar with this backup process, you might want to automate it with crontab.
It is worth noting that you do not have to create a boot image backup separate from the root folder backup. You can image the entire drive (usually /dev/sda), and split it into smaller files for transfer. However, I created these steps separately because in most restore circumstances, a full restore of the entire disk isn't necessary. When deploying this backup solution, you should also take note of "fdisk -l" output, so you know what partitions were on the system and their sizes in the event you have to restore the entire system. You would have a much easier restore process if you setup the disk partitions to match what you had originally prior to restoring the data on them.
If you split your files, and you need to restore them... you will need to recombine them first, using...
Comments (2)
Commented:
One little question. Is it possible to upload into a certain google drive folder?
I checked the Docs, but i didn't find anything..
Thanks Capo
Author
Commented:-p, --parent <parent> Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents
To get the folder id you can use 'drive list'