![]() ![]() I’ll use tar to archive all files in one and gzip to compress this file. Most of the time, we use compression for backup or at least archive files. If you want to use a different destination, you just have to update the variable at the beginning. The result will be the same, but it will be easier to update. I’ll also do the same for the “cp” command, so if you want to change it to use rsync or another command, you’ll have only one line to edit. You’ll have to edit 200 lines in your script to change the destination folder.Ī better way to do this is to create a variable at the beginning with the destination folder path and use it for each line. The first good practice we’ll use to improve the scripts is to add variables.įor example, let’s say you have 200 files to backups to /home/pi/backups and tomorrow you want to save them in /media/nas/pi/. So now we’ll improve this script on several points.Īre you a bit lost in the Linux command line? Check this article first for the most important commands to remember and a free downloadable cheat sheet so you can have the commands at your fingertips. Use sudo if needed (if the goal is to back up system files, you probably need sudo).Īs you can see, it’s a basic script, that will overwrite the old backup each time. Then add the permission to execute the script with: I’m using “/home/pi” everywhere, but you probably have to adjust this with your username (/home/pat for example).Īnd finally, the first version of a simple script could look like this: #!/bin/bash Then we need to create a backup folder to store the files: ![]() In my script, I’ll use a file and a folder that you can adapt to your needs: How to send the file to another computer (in the script or manually).īefore starting to create the script, you have to identify the files you need to save. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |