I am trying to write an alias that puts a folder and its subfolders/files into an encrypted archive titled with the date the command is run. Preferably in format "YYYYMMDD FolderName Backup".
E.g. replace YYYYMMDD with 20150707 or whatever day the command is called.
I know how to set an alias by editing/creating the .bash_aliases file in the Home folder and adding a line like this:
alias cryptdoc="cd ~/Desktop/ && 7z a -pSome_Pass -r ~/Desktop/YYYYMMDD_Documents_Backup.7z' '/home/location/Documents/'"
A few quick notes on the code above:
alias cryptdoc=sets up the alias.
- The quotes are included in case I have some directory with a space in the name so that I can write a command like "cd '~/My Documents/Folderhere'" which I might need to work without messing up the command.
cd ~/Desktop/is because I want the file to pop out on the desktop
&&is included to make sure I can do the first command and then the second as long as the first one works.
7zbecause it is better,
ato add a file to an archive and
-pto include a password within the command of my choosing. Keep in mind if you add a password after
-pthat it should look like this:
-ris because I want it recursive through my folders and files within the main folder.
I also realize that this means there will be a password in plain text on my machine in the alias file. But if someone has access to the alias file they also have access to my folder with these files in it anyway so it becomes irrelevant.
This should let me just go to terminal and type in
cryptdoc and hit enter in order to create a 7-Zip file encrypted with my chosen password all ready for upload to some less-secure cloud storage. But How can I add a variable that actually grabs the YYYYMMDD at the time of typing cryptdoc into terminal and inserts it into the title of the document?