If you want to backup files or directories in Linux you usually perform this command.

tar czpf directory_file__archive.tgz directory_file__archive

but what if your inside the directory and just want to backup certain files inside that directory. The trick is you need to create a file and put all the files you want to exclude.

vi exclude_file_directory
file1
directory1
directory2
file2

Now save the file and run this command to exclude files or directories you don’t want to archive.

tar czpfX archives.tgz exclude_file_directory *

Now if you want top extract the file just use.

tar xzvf archives.tgz

Here is a simple backup script.
create a file and name it as backup.sh and change permission of the file to 750

chmod 750 backup.sh

#!/bin/bash
dt=`date -I`
tar -czpf /backup/archive-$dt.tar.gz archive

Like this blog? Why not buy me a cup of coffee?