3

I have following line to zip/backup my home folder

sudo 7z a -p /backups/`date "+%Y%m%d"`.backup.7z ~

Please advise how would I add another folder in the same line to be backed up?

Currently it is backing up my home folder ~

I would like to add also /etc/folder1 in the line.

Zanna
  • 70,465

1 Answers1

3

Simple that:

# note the space between '~' and '/etc/folder1'
sudo 7z a -p /backups/`date "+%Y%m%d"`.backup.7z ~ /etc/folder1

You can give more than one target to put into a 7z file by simply statig each path for its own, separated by a '' (space). Example for better reading:

7z a <archive-file> <path1> <path2> ... <path_n>

Note: You can avoid backticks in your command by using $():

sudo 7z a -p "/backups/$(date +\%Y\%m\%d).backup.7z" ~ /etc/folder1
Videonauth
  • 33,355
  • 17
  • 105
  • 120