This is a very very very basic UNIX/Linux script you can make to save all your files in one folder.
I will try to make it so you can use it on any linux system. Lets pretend you have a file called music,
and you want to back it up to an external drive. I’m going to assume you have it already mounted. I’ll call
the external drive disk and the music file is in your /home/”user name”/ folder.
#!/bin/bash
#simple backup script
echo “Backup has started.”
mkdir $USER
cp -R /home/$USER/music /mnt/disk
echo “Backup is finished.”
This is a very very very simple script. I may later show a more advanced one but for now this is just an
example. If you just want to move the files completely instead of copy them then change the line where cp -R
is to “mv /home/$USER/music /mnt/disk”. That will move the files to the new folder(type it without the quotes
ofcourse). Also i use $USER to be the directory being created which makes the folder your username but you can
change it to anything like “mkdir Backup_music” or somthing along those lines.
I hope some people new to shell scripting found this useful i wanted it to be something easy that Linux users
can use if they are learning to shell script or dont know much about the terminal but want to backup some files.
Oh one more thing you can copy as many files to the new directory as you want I only show one for this example.
