7zip command-line backup

Any topic that does not fit into the other categories.
Post Reply
Message
Author
User avatar
webfork
Posts: 7758
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

7zip command-line backup

#1 Post by webfork » Fri Sep 02, 2016 6:52 am

Background: I frequently backup a folder of important files to a Google Drive account using 7zip to both compress and encrypt it. I've been looking for a way to automate this process. I've already made the upload process a lot easier via ShareX's folder watch function but for the compression, I'm trying to speed up the sequence with standard 7-zip.

The goal here is to spend a little time on automation to save a lot of time and boring, repetitive effort over months and years. I've also more than once accidentally failed to add a password.

As many users are going to run this sort of thing on USB drives and cloud drives, I'm doing everything here with relative folders (e.g. .\output rather than z:\output)

Steps:
  1. Download and extract the 7za.exe file from 7-Zip Command Line Version site (http://7-zip.org/download.html) page and save it to the folder below the one you want to compress (in this example "FILES")
  2. Create two empty text files and save them as Compress.bat and Extract.bat
  3. Open both files and paste in the green text below:

    Compress.bat file

    Code: Select all

    7za u -mx9 -r -mhe -pSECRETCODE Backup.7z ./FILES/*
    • Explanation: This tells the computer you want to create (or update if already present) a Backup.7z file using the files in the local directory FILES and all it's subdirectories [-r] using the highest compression level [-mx9]. This will use encrypted headers (the file names are obscured) and the password "SECRETCODE" [-mhe -pSECRETCODE]
    Extract.bat file

    Code: Select all

    7za.exe x Backup.7z -o.\OUTPUT -pSECRETCODE
    • Explanation: This tells the computer you want to extract the Backup.7z file to the local folder "OUTPUT" with the same password from above
  4. Change the "SECRETCODE" to something else, ideally 15+ characters using a password generator.
  5. Launch either the Compress.bat or Extract.bat depending on your location (either beginning or destination computer)
More information / Where I Did My Research:
Other notes
  • Large backups - If you have a ton of files or a very old computer, this setup can take a lot of time. You may want to change -mx9 to -mx5 (default) or -mx2 to lower the compression level.
  • Security: This process will save the password locally to your computer. If that's an issue, you may want to run this from inside an encrypted volume like VeraCrypt or Truecrypt.
  • Compressing text files - available PPMD compression can create some dramatic space savings (http://www.dotnetperls.com/7-zip-examples)
- - -

Feedback welcome.
Supporting Net Neutrality - BattleForTheNet | Why this matters | More from EFF.org

User avatar
smaragdus
Posts: 1967
Joined: Sat Jun 22, 2013 3:24 am
Location: Aeaea

Re: Ding-Press

#2 Post by smaragdus » Thu May 24, 2018 2:08 pm

@Ding-A-Ling

Thank you for the nifty little tool. I tested Ding-Press and it worked fine.

Screen:

Image

Observations:
  • I tried to add more passwords using the pattern from the INI file but it turned out that the program is set to use only passwords from 0 to 9.
  • The program is set to stay on top.
  • The program is tiny (923 KB executable) and light (it uses about 16 MB of RAM).
  • The program has tray icon but cannot be minimized to tray only (not shown in taskbar).
Enhancements:
  • Option to "minimize to tray" - for example:

    Code: Select all

    tray=1
    parameter in INI file;
  • If "minimize to tray" is implemented - new tray command above "Script Paused" and "Exit" - "Open";
  • Option to "save window state on exit" (position on desktop), for example;

    Code: Select all

    window=1
    parameter in INI file;
  • Option to use more passwords than 0-9 - program checks the INI file for the number of added passwords;
  • Version number in title bar;
Overall, Ding-Press is a very promising tool. Thanks for sharing it, Ding-A-Ling.

User avatar
smaragdus
Posts: 1967
Joined: Sat Jun 22, 2013 3:24 am
Location: Aeaea

Re: 7zip command-line backup

#3 Post by smaragdus » Thu May 24, 2018 2:12 pm

It seems that user Ding-A-Ling deleted his post while I was replying to it.

billon
Posts: 560
Joined: Sat Jun 23, 2012 4:28 pm

Re: 7zip command-line backup

#4 Post by billon » Thu May 24, 2018 6:10 pm

:?:

User avatar
Ding-A-Ling
Posts: 9
Joined: Sun Jul 23, 2017 2:33 am
Contact:

Re: 7zip command-line backup

#5 Post by Ding-A-Ling » Fri May 25, 2018 12:58 am

3nd Repost (I'm sorry about that but I just keep finding problems with it):

I've attempted to expand upon Webfork's idea.

It's somewhat naively programmed in AutoIt with absolutely NO WARRANTY.

The program — such as it is — is reasonably self-explanatory (ie. I think people will be able to work it out by having a quick play-around).
Passwords are stored in "plain sight" in the ini.txt. Like Webfork said about his batch-script idea: "If that's an issue, you may want to run this from inside an encrypted volume like VeraCrypt". (Perhaps, in the future, I could add a modicum of password-management with AES-256 encryption, but this is just a first version and there might be very little interest.)
If you're going to try this, you'll need to change the passwords that are already in the ini.txt.
The program has buttons for picking files and folders and the input boxes accept the dragging-and-dropping of file- and folder-names.

If used in the SendTo menu, it quickly:
  • decompresses .7z, .rar and .zip files
  • compresses folders and other files using the highest compression-level (not suitable for large folders/files).
Download v1.48.1
4Shared or Mediafire

____________________________________________________________________________

@smaragdus: Thank you for your interest, positive comments and constructive criticisms.
(I've implemented your suggestions.)

:D
Last edited by Ding-A-Ling on Tue Jun 12, 2018 4:53 am, edited 2 times in total.
DAL's Programs
Image I wanna play with my ding-a-ling! Image Image

User avatar
Ding-A-Ling
Posts: 9
Joined: Sun Jul 23, 2017 2:33 am
Contact:

Re: 7zip command-line backup

#6 Post by Ding-A-Ling » Tue Jun 05, 2018 1:23 am

webfork wrote:
Mon Jun 04, 2018 12:37 pm
Ding-A-Ling wrote:
Mon Jun 04, 2018 12:16 am
Well, do you think that it is even good enough to share? If you thought it was, I'd have to consider it.

If I released the source code generally, would you vote for the compiled version's inclusion in TPFC's public database?

How does licensing work? Is it just a statement in a read-me file? If not, how involved is the process to license one's work? Is it free?

To use, say, the MIT licence, would I need to pay for legally recognised copyright first?
Could we move this conversation to the forums? So many of these topics come up so frequently, I'd like to answer these in the forums so I can reference this conversation later.

No, it doesn't cost anything. A license literally is just attaching a file with some text and your copyright. That affords you real legal protection. If you use a standard license, other people with that same license (who want to protect their work as well) will come to your aid should you end up in court. This has happened many times for many developers of GPL code over the years.

As to whether it's good enough, I don't know. The screencap that I saw looked promising.

I don't want to say I'll vote for it before I test it. However, if the program works as described and it saves time over the (rather lengthy) command-line process I mentioned in the 7zip command line thread, I will definitely vote for it.
Download v1.48.1 with AutoIt source code:
MediaFire
Last edited by Ding-A-Ling on Tue Jun 12, 2018 4:53 am, edited 1 time in total.
DAL's Programs
Image I wanna play with my ding-a-ling! Image Image

User avatar
webfork
Posts: 7758
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: 7zip command-line backup

#7 Post by webfork » Sat Jun 09, 2018 10:17 am

Thanks for both posting that and moving that conversation to the forums. More to come.
Supporting Net Neutrality - BattleForTheNet | Why this matters | More from EFF.org

Post Reply