Giter VIP home page Giter VIP logo

pi-safe's Introduction

PiSafe - Raspberry Pi imaging app

Backup or Restore Raspberry Pi media (SD-cards, USB sticks, SSD drive, ...) to/from compressed image-files right on your Pi!

  • Backup an SD card (or other media) to an image-file.

  • Restore an image-file to an SD card (or other media).

  • Works entirely on a Raspberry Pi (or other linux). No Windows or Mac needed.

  • Creates a compressed image-file that will resize to fill the new media to which it is restored.

  • Supports .img .zip .xz .gz and .zst file formats.

  • Images are compatible with popular imaging software such as Raspberry PI Imager.

  • Supports USB storage devices.

  • Supports backing up the live boot media - but be careful, backing up media that is being written to can result in a corrupted backup. You have to turn off "hide root device" in "settings", "options" to enable this.

    CAUTION: Reboot first, close everything and don't use the system while it is doing step 1 of backing up! You must send your backup image to a different drive.

  • Supports storing the image files on a mounted network device (ie an SMB server). Some help...

    • sudo apt install cifs-utils

    • mkdir shared

    • sudo mount.cifs //192.168.1.18/shared shared -o user=USERNAME,vers=1.0

    • or

    • sudo mount.cifs //omv.local/shared shared -o guest

  • Create a library of your own pi images, then restore them to whatever media you want, whenever you want.

  • Can be run from the command line or use the easy menu-driven interface.

  • Should work with most debian and arch distros, see below.

  • See Leepspvideo nice review on youtube: https://www.youtube.com/watch?v=XP6ycUR9Ih0 -- "Very Impressive", "Makes a nice small image", "Really good all-in-one solution"

Install

Paste or type this into a terminal window:

wget https://raw.githubusercontent.com/RichardMidnight/pi-safe/main/pisafe -O pisafe
bash pisafe install

Beta version:

wget https://raw.githubusercontent.com/RichardMidnight/pi-safe/main/pisafe_beta -O pisafe
bash pisafe install

Old Stable (in case current ver has issues)

wget https://raw.githubusercontent.com/RichardMidnight/pi-safe/main/pisafe_1.2.9 -O pisafe
bash pisafe install

Simple Setup

  1. Install Raspberry PI OS and PiSafe on an SD card that is large enough to hold some SD image-files. 32GB or 64GB will do. This is your "Master" SD-card. Set this aside.

  2. Install Raspberry PI OS or whatever OS you want on the "Source" SD-card. Use as small of an SD-card as you can because the entire card is read before it is shrunk and compressed. I have been using Sandisk Industrial 8GB cards. Make changes, install other software, change the desktop, whatever you want.

  3. To make an image of the "Source" (8GB) card that you can restore anytime in the future do the following...

Usage - make an image file

  1. Boot your Pi with your "Master" SD-card as above.

  2. Put your "Source" SD-card (8GB) in the USB SD reader and insert it in a Pi USB port.

  3. Startup pisafe from the menu. Or in a terminal, type in 'pisafe'

  4. Use the menu to select BACKUP, select your SD-card and give the image-file a name.

  5. Watch your image-file get created, shrunk and compressed automatically.

Release notes

Originally developed and tested on Raspberry pi 4 running Raspberry Pi OS Buster.

Also tested on RaspiOS-arm64, Raspberry Pi Desktop, Raspbian Stretch, Ubuntu 20.20 for Rpi, Linux Mint, LMDE.

v1.0.5 Added support for other terminals: lxterminal, gnome-terminal, xfce-terminal, mate-terminal, konsole, xterm, uxterm, qterminal.

V1.0.5 Added support for other text editors: leafpad, mousepad, gedit, kwrite, pluma, featherpad, xed, geany, kate, nano.

V1.1.0 Added support for Manjaro and probably other Arch-based distros.

v1.2.0 Cleaned up the code a lot, added "ignore_freespace_at_end", added erase (fat32, exfat, ntfs, ext4).

v1.2.3 Cleaned up more code. Fixed bug in available-space on network-shares which halted backup.

v1.2.4 Cleaned up more code. Backup with -y bypasses check_for_updates.

v1.2.5 Improved support for Manjaro, Arch, Suse and Fedora.

v1.2.5m Fixed issue with non-english languages. Added support for zstd compression. Made gz, xz and zst only install as needed.

v1.2.7 Fixed issue with pigz and xz.

v 1.2.9 Started to add command-line settings-override options (undocumented at this point).

v 1.2.10 Adds support for Bookworm and NVME media

Tips

PiSafe is optimized for Raspberry Pis running Raspios around the year 2020. It will work with many other linux distributions and other hardware but some features may not be optimized or may not work at all depending on the configuration. The following tips can help you optimize PiSafe for your configuration.

  • Ignore Freespace at end of media

    • PiSafe will ignore freespace at the end of the media, speeding up the backup process and using less working space.
    • If you have a small amount of data on a large media (eg using 10GB of a 500GB drive), you can resize your partitions (with gparted) and leave freespace (unallocated) at the end of the media which PiSafe will ignore. Note, freespace not at the end of the media cannot be ignored.
  • Shrinking the filesystem on backup

    • Shrinking the filesystem is VERY VALUABLE because it creates a smaller image file, and allows you to restore the image to a different size media.
    • PiSafe will shrink your filesystem if your main partition is ext4 (or ext3 or ext2) and is the last partition on the media.
    • If your install does not default to this partitioning setup you should be able to custom partition the media during your OS installation and put the main ext4 partition at the end. This is needed with standard debian installations including RPD and Linux Mint because they put a swap partition at then end of the media which blocks PiSafe from shrinking the filesystem.
    • Alternatively if your main partition is the second to last one and the last one is a swap partition, you may be able to simply delete the swap partition.
    • Alternatively you can zero-out your deleted files with bleachbit to optimize compression and then shrink your partitions with gparted.
  • Auto-expand filesystem on restore

    • PiSafe will setup the image file to auto-expand to fill the new media on first boot after restoring if your distro supports rc.local.
    • If not, you can resize your partition manual by booting from another media and using gparted.
    • Note: Auto-expand may not work on an overlay filesystem. Recommend turning off auto-expand in Settings/Options.
  • Data compression

    • Compressing the image file with zip, xz, gz, or zst reduces the size of the image file to around 1/2.
    • Standard compression levels are 1 through 9. A higher number will compress the file a little more but take a lot more time.
    • fastest is "zst 1".
    • smallest is "xz 8" (or as high as memory allows).
    • PiSafe default is industry standard "zip 1".

References

Thanks to the Raspberry Pi foundation for instructions on how to read and write an image file.

Thanks to https://github.com/Drewsif/PiShrink for the PiShrink engine.

Thanks to all the people who posted code snipets on the web.

pi-safe's People

Contributors

richardmidnight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pi-safe's Issues

[Question]Is there any possiable to backup without a second SD/USB/HDD?

Can this script add feature “pre-allocated an *.image which the size is 300MB(optioned) biger than the used space ”, and rsync the files to the blank image(exclude the image path),this will allow backup with only one SD card , because pre-allocate image size is auttually 'pre -pishrinked' and can locate in the free space .there were used to be another script using this method ,but it seems the author wont maintain it anymore,it abit buggy for only support sd card boot(released before raspi support usb boot)
https://github.com/nanhantianyi/rpi-backup/blob/master/back.sh

Attempting to view PiSafe logs with mousepad generates several deprecation errors

Hello RichardMidnight,
When attempting to view the backup log in PiSafe, the terminal window reports the following errors:

(mousepad:11129): Gtk-WARNING **: 12:29:06.813: Theme parsing error: :2:29: The style property GtkButton:default-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(mousepad:11129): Gtk-WARNING **: 12:29:06.813: Theme parsing error: :3:37: The style property GtkButton:default-outside-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(mousepad:11129): Gtk-WARNING **: 12:29:06.813: Theme parsing error: :4:27: The style property GtkButton:inner-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(mousepad:11129): Gtk-WARNING **: 12:29:06.813: Theme parsing error: :5:31: The style property GtkWidget:focus-line-width is deprecated and shouldn't be used anymore. It will be removed in a future version

(mousepad:11129): Gtk-WARNING **: 12:29:06.813: Theme parsing error: :6:28: The style property GtkWidget:focus-padding is deprecated and shouldn't be used anymore. It will be removed in a future version

Note: Log file opens in mousepad as expected, so it's working currently. But it may not if/when mousepad gets updated and wanted to call your attention to it.

Environment:
PiSafe version: 1.0.0
OS Mod: Twister OS version 2.0.0
OS: Raspbian GNU/Linux 10 (buster) aarch64
Host: Raspberry Pi 4 Model B Rev 1.1
Kernel: 5.10.17-v8+
Shell: bash 5.0.3
CPU: (4) @ 2.000GHz
Memory: 616MiB / 3742MiB
Disk (/): 11G / 110G (10%)

Feature Request: integrate gpg encryption of images

This tool is the answer to a long search of mine, so thanks a ton! <3

I have one possible feature request, although I personally classify it as low-priority since it can easily be added manually: I'd like to see added GnuPG encryption of the compressed archives (*.img.zip.gpg and alternatives).

I do this to have encrypted files be transferred to offsite backup sites that I don't fully trust.

One way to do this would be to ask for a GPG key id at some point in the backup / restore process or via commandline parameter, then run gpg --encrypt --recipient [KEYID] ~/Downloads/backupfile.img.zip and remove the .zip file later.

Alternatively pipe the *zip command into gpg directly and never store the .*zip file on disk in the first place. This is probably faster and preferred by the paranoid since it won't leave unencrypted artefacts on the local harddisk.

Example for gzip:

gzip --stdout - | gpg --encrypt --recipient $GPGKEYID --output $TARGETFILE

Thanks for your consideration

Some PiSafe GUI recommendations

Hello RichardMidnight,
I wanted to suggest some (hopefully) helpful improvements to the GUI for PiSafe.
You are free to ignore any (or all) of the recommendations I will be suggesting below, and I won't be offended.

With that said, I will list out the recommended changes, and also attach some screen captures to help illustrate where in the PiSafe GUI I'm referring to.

Main Menu:
1) I would advise replacing the selectable blank space with a non-selectable horizontal line (see GUI-1.png below).

GUI-1

Settings Menu:
1) I would advise replacing the selectable blank space with a non-selectable horizontal line.
2) I suggest changing the <'Cancel'> button text to read <'Back'> or <'Back to Main Menu'>, to be less confusing (see GUI-2.png below)

GUI-2

Tools Menu:
1) I would advise replacing the selectable blank spaces with non-selectable horizontal lines (or remove them altogether).
2) I advise changing "ABOUT PiSafe" to read "About PiSafe" to keep the overall wording consistent on this page.
3) I suggest changing the <'Cancel'> button text to read <'Back'> or <'Back to Main Menu'>, to be less confusing (see GUI-3.png below).

GUI-3

Finally, under the Help Menu, you might want to include an example of how to save a PiSafe image up to a network share.
EG: pisafe backup /dev/sda /mnt/synology/TwistedOSv20_date +"%m-%d-%Y_%I%M%p".img.gz

Note: This is the string I'm using in crontab (once a week) to help me capture a backup of my RPi4b, so you would want to design a more generic example for inclusion under the help section.

Thank you again for all your time and efforts in making PiSafe what it is today!

nvme support?

Hi - Thanks great piece of software!

With the new rpi5 coming out...and, in support for x86-based systems, is it possible to set up nvme-based systems? I've successfully run pi-safe on Debian/x86-based systems with SSD's (ie, /dev/sd*1), but when I try to configure on a Debian system with / mounted on /dev/nvme0n1, it doesn't show up in the media screen - STORAGE MEDIA (hide root device = off) . Not sure if this is an enhancement request or a configuration issue.

Thanks!

tar compression?

Could you add the ability to compress the sd card as a .tar archive?
Once that's working, it ought to be fairly simple to also add tar.xz and tar.gz support.

CLI backup issues

  1. If curent folder differ then destination then backup will not work (free space issue)

root@rpi4:/home/kdn# pisafe list
--- CURRENT SYSTEM ---
PiSafe ver 1.2.0
Raspbian GNU/Linux 11 (bullseye) hw=armv7l kernel=5.10.92-v7l+
Root device = /dev/mmcblk0
Size = 29.7gb
FreeSpace = 20.4gb
TrashSize = 0
RootTrash = 0

--- STORAGE MEDIA (hide root device = ) ---
/dev/sda DISAIN Dual_Flash_Drive 234.4G
/dev/mmcblk0 29.7G

--- IMAGE FILES in '/home/kdn' (20.4gb free) ---
FILE_NAME FILE_SIZE (IMAGE_SIZE)
root@rpi4:/home/kdn# cd /media/USBFD256G/
root@rpi4:/media/USBFD256G# pisafe list
--- CURRENT SYSTEM ---
PiSafe ver 1.2.0
Raspbian GNU/Linux 11 (bullseye) hw=armv7l kernel=5.10.92-v7l+
Root device = /dev/mmcblk0
Size = 29.7gb
FreeSpace = 185gb
TrashSize = 0
RootTrash = 0

--- STORAGE MEDIA (hide root device = ) ---
/dev/sda DISAIN Dual_Flash_Drive 234.4G
/dev/mmcblk0 29.7G

--- IMAGE FILES in '/media/USBFD256G' (185gb free) ---
FILE_NAME FILE_SIZE (IMAGE_SIZE)
root@rpi4:/media/USBFD256G#

  1. Compression set to level of 9 - what is compression level, why it empty?

root@rpi4:/media/USBFD256G# pisafe backup /dev/mmcblk0 /media/USBFD256G/rpi4backup/backup_$(date +%Y-%d-%m_%I%M%p).img.gz
Starting PiSafe 1.2.0 Backup...
IN-DEV='/dev/mmcblk0'
OUT-FILE='/media/USBFD256G/rpi4backup/backup_2022-23-01_0427PM.img.gz'
Compression set to level of 9
PiSafe: WARNING 3: SD-card ' - 29.7G (/dev/mmcblk0)' is root device '/dev/mmcblk0'.
PiSafe: WARNING 4: ' - 29.7G (/dev/mmcblk0)' is larger than 16GB.

Use a smaller SD card if you can.
It will be faster because the entire SD card must be read before it can be compressed.

A good 8gb card with RaspiOS in a Raspberry Pi 4 takes about 10 minutes
Step 1 of 3 - Reading '/dev/mmcblk0' to '/media/USBFD256G/rpi4backup/backup_2022-23-01_0427PM.img' ...
Sun 23 Jan 2022 04:27:35 PM EET
Media size=29.7gb
Skipping 0 of freespace at end of media.
Reading=29.7gb
1.56GiB 0:01:02 [34.6MiB/s] [========>

SD Card Copier

First off I would like to say that I really like the idea of Pi-Safe. An improvement that I thought of would be an SD card copier. This would copy the internal storage to an external storage device.

Best Regards, SlashTechno

Support of ZStandard compression

Hi, now that Raspberry Pi Imager imager support the .zst compression as direct input image to flash a SD card, it would be nice to add this compression on ultra(22) which gave me better result on compression.

At this moment I have to use the "no compression" option and then compress my .img file with " zstd" or the 7-Zip ZStandard fork.

I hope that could be easily added.

Thanks

Time after time

  1. idea Can you add some estimated time
    for create image
    and for compress

Or pointing me where in code I can do it.
Thx

Showing tons of invalid "img" files...

Example output of the "LIST" function:

    ~~~ IMAGE FILES in '/home/pi/Downloads' ~~~                                                                                                                                                                
    FILE_NAME                             FILE_SIZE  (IMAGE_SIZE)                                                                                                                                              
    ARChon-v2.1.0-arm.zip                 105mb      (239mb)                                                                                                                                                   
    Aster_Chat_Log_(1).zip                1.54mb     (0)                                                                                                                                                       
    Aster_Chat_Log.zip                    860kb      (0)                                                                                                                                                       
    bongocam.zip                          8.00kb     (0)                                                                                                                                                       
    Bongo.Cam.zip                         8.00kb     (0)                                                                                                                                                       
    control.tar.xz                        4.00kb     (0)                                                                                                                                                       
    data.tar.xz                           872kb      (0)                                                                                                                                                       
    FenixPiV0.9.1_4DE_Lite.xz             3.46gb     (0)                                                                                                                                                       
    Github-CLI.zip                        8.00kb     (0)                                                                                                                                                       
    Godot.Engine.3.2.4_(1).zip            8.00kb     (0)                                                                                                                                                       
    Godot.Engine.3.2.4.zip                8.00kb     (0)                                                                                                                                                       
    KSP_demo_win.zip                      464mb      (0)                                                                                                                                                       
    Linux-arm32-AppImage.zip              74.6mb     (0)                                                                                                                                                       
    Lokinet_dscrptn_tun_override_(1).zip  8.00kb     (0)                                                                                                                                                       
    Lokinet_dscrptn_tun_override.zip      8.00kb     (0)                                                                                                                                                       
    Michael_investigation_files.zip       1.83mb     (0)                                                                                                                                                       
    Minecraft.Importer.tar.gz             12.0kb     (0)                                                                                                                                                       
    Notepad.++.zip                        16.0kb     (0)                                                                                                                                                       
    Password.Manager.tar.gz               12.0kb     (0)                                                                                                                                                       
    pi-apps.zip                           15.9mb     (0)                                                                                                                                                       
    Remarkable.zip                        8.00kb     (0)                                                                                                                                                       
    RPi-Play.zip                          8.00kb     (0)                                                                                                                                                       
    Stunt.Rally.zip                       16.0kb     (0)                                                                                                                                                       
    takeout-20210324T180826Z-001.zip      53.3mb     (0)                                                                                                                                                       
    TurboWarp.zip                         8.00kb     (0)                                                                                                                                                       
    Wechat_(1).zip                        12.0kb     (0)                                                                                                                                                       
    Wechat.zip                            12.0kb     (0)                                                                                                                                                       
    zenity.sh.zip                         4.00kb     (0)                                                                                                                                                       
    zoom_i686.tar.xz                      38.5mb     (0) 

In addition, it missed all the image files that exist in /home/pi.

auto-expand of file system on restore stuck in a reboot loop because of overlay file system

discovered an issue where I backed up a system which was configured with overlay file system and read-only boot partition, it shrank it and when I restored it to a new SD Card it tried to auto-expand the filesystem to the media size, rebooted and then tried to expand again.. I couldn't figure out how to get out of this loop, so backed it up again but deselected auto-expand, then the restored image booted correctly.
I could then expand the filesystem after manually disabling the overlay filesystem and read-only partition.
Probably just needs a mention/caution in the docs, or if you can advise how to break out of the reboot loop I'll reproduce the issue.

SD card >16Gb: nothings happens after warning. No backup

I use a sd card 64Gb. pisave 1.2.9. Warning "57.9 > 16Gb, beter use 16Gb ore less, with ok selected and then enter.
Warning stays on. Nothing happens thereafter.
P400 with 4Gb nenory, bulseye 64
Try Start pisafe in terminal AND Menu

Request

Love the tool as is but wondered if there was a way to be able to utilize it for the current SD/SSD img being ran. So instead of having a spare card lying around that you boot up to backup your main SD/SSD, you can run the process for the current drive. If this is already possible, I just don't know how to do it then.

Not usefull if your system is on SSD

I cannot use it due it cannot detect my system on a SSD - so now I want to remove it again. It would be nice for beginners like me if you could mention how to remove it.

thank you!

Kind regards - Chobberr

Version 1.2.10 Slow

New version for my 64Gb Rpi4 image over 4 hours ?!?
This is toooo much. What is wrong ?

Source Disk, external 2,5 inch WD 250Gb on USB 2
Destination Disk external WD My Book 1.5 USB (also is slooow run, get me gun)

3 * 4 Hours, use USB2 All night party :)

Pisafe stalls on reading sdcard.

Hi people,

I'm in troubles trying to backup a SDCard using Pisafe 1.2.5

The SDCard is a Sandisk 32Gb with an Ubuntu 22.04 installed today. fsck told both part. are clean.

The S.O. I'm running Pisafe is a RPIOS Bullseye arm64 running on a RPI 4 8GB, from a USB stick Samsung 128 GB. I am sure I have room for .zip.

When executing Pisafe I get this output:

PiSafe 1.2.5
Checking for PiSafe updates...
PiSafe 1.2.5 Backup...
No extension specified. Adding '.img.zip'
OUT-FILE='/media/pi/BKP1/PISafe/2022-04-10-ub2204nosnap.img.zip'
29.7gb to read from '/dev/sda'

And thats all, after 2 hours nothing have changed on output.

Tried once more, and same behavior...

I've chose another SDCard and installed a RPIOS Buster Legacy and set up Pisafe and same behavior.

After this changed hardware to a RPI 4 4GB and same behavior.

And than changed to a Ubuntu 22.04 beta installed on a SSD and same behavior.

/Downloads$ bash pisafe
PiSafe 1.2.5
Checking for PiSafe updates...
PiSafe 1.2.5 Backup...
[sudo] senha para vieira:
No extension specified. Adding '.img.zip'
OUT-FILE='/media/vieira/compart8/2022-04-11-teste.img.zip'
29.7gb to read from '/dev/mmcblk0'

With this log file:

2022-04-11 00:39 Installing pishrink...
2022-04-11 00:39 Installing pigz...
2022-04-11 00:39 Installing pv...
2022-04-11 00:45 PiSafe 1.2.5 Backup...
2022-04-11 03:45 PiSafe 1.2.5 Backup... <<<=====

Now it is 04:57 more than 1 hour...

With this log file:

/home/vieira/.config/pisafe/pisafe.conf

settings_script_ver=1.2.5
default_path_cli_from_settings=off
default_path=/media/vieira/compart8
check_for_updates_on_startup=on
check_dependencies_on_startup=on
debug_mode=on
sound=on
log=on
text_editor=gedit
hide_root_device=on
shrink_fs=on
auto_expand_fs=on
default_extension=zip
compression_level=5
parallel_compression=on
large_device_read_warning=16gb
skip_freespace=on
large_device_write_warning=16gb
safety=on

I cant imagine what I'm doing wrong.

Until ver 1.1.1 it was working pretty good...

Is there a way to downgrade to ver 1.1.1???

Thanks for your attention,

Cury

Samba? pisafe.tmp?

Hi there, first I'd just like to say thank you for making sd/pi-safe. They are awesome.

Will it work with copying root/active distro to a remote samba share?

Also, why does it create pisafe.tmp in every directory it's ran from?

[Feature Request] Export log file with the creation of backup image

Hello RichardMidnight,
Would it be possible to include a choice that would allow the log file to be written to the same directory the backup image is created in?
Either as a variable/condition to set in the PiSafe config file and/or via a CLI function?

That logging option should allow me to better track PiSafe's speed/performance over time.

[Feature Request] Adding in a choice to review logs using nano instead of using mousepad

Hello RichardMidnight,
Would it be possible to include a choice in PiSafe that could allow the backup logs to be opened with nano instead of mousepad?

I tend to connect to my Raspberry Pi 4 over SSH to kick off backups. Once backup completes, I find I cannot view the backup log, as PiSafe cannot invoke mousepad while SSH'd in.

Having a prompt/option to view the logs with nano (or some other terminal based editor) during a SSH session, would be very helpful for my needs.

pigz not working

~ Running: pv '/home/pi/2023-02-11-pisafe.img' -p | pigz --best= -1 > '/home/pi/2023-02-11-pisafe.img.gz'
pigz: abort: invalid option: --best=
[> ] 0%
~ Exit_Status 22 running 'pv '/home/pi/2023-02-11-pisafe.img' -p | pigz --best= -1 > '/home/pi/2023-02-11-pisafe.img.gz''

with --best= -5 or --best= -9 is it the same issue

Tooo loooong

Hi again me

Version 1.2 11
for my great wdc old laptop hdd 250Gb over 6 hourse ????? only for 1. step. About cca 16 Mb/s.
Ubuntu 20.04 RPI4 4Gb.
When finish take screenshoot to this.

Can I some speed up this routine ?

pi-safe install issue in ubuntu server 20.04 LTS 2

Hi,

I did not have lua installed in the ubuntu server initially. I installed it with following command:

sudo apt-get install liblua5.1-0-dev liblua50-dev liblualib50-dev

Then I attempted again to install pi-safe and got following errors:

lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read default_path: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read default_extension: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read compression_level: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read allow_root_backup: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read debug_mode: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read sound: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read shrink_fs: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read safeties: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read default_path: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read default_extension: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read compression_level: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read allow_root_backup: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read debug_mode: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read sound: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read shrink_fs: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read safeties: No such file or directory
mkdir: cannot create directory ‘’: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read default_path: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read default_extension: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read compression_level: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read allow_root_backup: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read debug_mode: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read sound: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read shrink_fs: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read safeties: No such file or directory
mkdir: cannot create directory ‘’: No such file or directory
pisafe: line 49: [: =: unary operator expected
pisafe: line 52: [: =: unary operator expected
pisafe: line 55: [: =: unary operator expected
pisafe: line 58: [: !=: unary operator expected
pisafe: line 61: [: =: unary operator expected
pisafe: line 64: [: =: unary operator expected
pisafe: line 67: [: =: unary operator expected
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read default_path: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read default_extension: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read compression_level: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read allow_root_backup: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read debug_mode: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read sound: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read shrink_fs: No such file or directory
lua: stdin:1: attempt to index global `arg' (a nil value)
stack traceback:
	stdin:1: in main chunk
	[C]: ?
lua: cannot read safeties: No such file or directory
mkdir: cannot create directory ‘’: No such file or directory
Install needed tools:  PiShrink, zip,  and xz-tools?

Any ideas what lua version I need to install ubuntu server? I presume ubuntu server is supported?

Hide dvd drives

Output of the "LIST" command:

    ~~~ SD-CARD DEVICES ~~~  (hide root device = on)                                                                                                                                                           
    /dev/sdb      Generic  STORAGE_DEVICE       29.7G                                                                                                                                                          
    /dev/sdc      WDC WD10 EALX-759BA1         931.5G                                                                                                                                                          
    /dev/sr0      PLDS     DVD+-RW_DH-16ABS      6.9G                                                                                                                                                          
    /dev/pktcdvd0                                6.9G 

/dev/sr0 and /dev/pktcdvd0 are dvd drives. They don't actually contain any dvds at the moment.

I doubt anyone will ever want to use your tool to copy tata from a dvd drive, so would you consider hiding these devices?
In my scripts, I use this:

lsblk -I 8,179 -dno PATH,SIZE

Uninstall

Is it possible to make an automated uninstall?

Syntax error on Debian 11.

Hi Richard,

I've been using Pisafe a lot in Ubuntu, RPI OS and I am sure it is a great tool.

Today I am trying to use PiSafe on my new SBC, Orange PI 5, formatted with Debian 11 - KDE
and incredibly I am receiving these 3 error messages.

My problem is solved cause I Still have RPI 4 and PiSafe is working good on it.

Stay safe and healthy,

cury@opi5ssd2:$ sh ./pisafe.sh
./pisafe.sh: 455: Syntax error: "(" unexpected (expecting "}")
cury@opi5ssd2:
$ ls -l
drwx------ - cury 12 jan 20:51 Desktop
drwxr-xr-x - cury 11 fev 0:10 Downloads
drwxr-xr-x - cury 20 jan 2:52 Imagens
drwx------ - cury 12 jan 22:18 NoMachine
drwxr-xr-x - cury 9 fev 4:10 Pictures
.rwxr-xr-x 71k cury 13 fev 3:44 pisafe.sh
.rwxr-xr-x 71k cury 13 fev 3:49 pisafe_1.1.1
.rw-r--r-- 85k cury 13 fev 3:49 pisafe_1.2.5
drwxrwx--x - cury 12 fev 21:25 Videos
cury@opi5ssd2:$ sh ./pisafe_1.1.1
./pisafe_1.1.1: 455: Syntax error: "(" unexpected (expecting "}")
cury@opi5ssd2:
$ sh ./pisafe_1.2.5
./pisafe_1.2.5: 690: Syntax error: "(" unexpected (expecting "}")
cury@opi5ssd2:~$

Backup to samba share ?

Is it possible to backup a running system to a windows samba share (then use that backup and write it to a bootable USB) ?

On backup, always installing pishink

Hello, and thank you for the great script that you created!
I'm using it from cron with a script, with a little problem...

The script that is called from cron (pisafe_backup.sh):

#!/bin/bash
rm /home/root/.config/pisafe/pisafe.log
/usr/local/bin/pisafe backup /dev/mmcblk0 /mnt/extra/system_backup/backup/shrinked/'rPI
'$(date +%d%m%Y)'.img' -y_

The problem is , that on every single run, in the log file, i see that your script, always downloads and install pishrink.sh (even if the file is already downloaded)

2023-03-28 10:00 Installing pishrink...
2023-03-28 10:00 PiSafe 1.2.9 Backup...
2023-03-28 10:00 ~ PiSafe 1.2.9 Backup '/dev/mmcblk0' to '/mnt/extra/system_backup/backup/shrinked/rPI_28032023.img'
2023-03-28 10:00 ~ Step 1 of 3 - Copying '/dev/mmcblk0' to '/mnt/extra/system_backup/backup/shrinked/rPI_28032023.img' ...
2023-03-28 10:00 ~ Running: sudo pv /dev/mmcblk0 -p -s 15552479232 | sudo dd bs=4194304 of='/mnt/extra/system_backup/backup/shrinked/rPI_28032023.img' count=3709 iflag=fullblock conv=fsync
2023-03-28 10:13 ~ Step 2 of 3 - Shrinking filesystem ...
2023-03-28 10:13 ~ Running: sudo pishrink.sh '/mnt/extra/system_backup/backup/shrinked/rPI_28032023.img'
2023-03-28 10:26 ~ Step 3 of 3 - Compressing '/mnt/extra/system_backup/backup/shrinked/rPI_28032023.img' to '/mnt/extra/system_backup/backup/shrinked/rPI_28032023.img' ...
2023-03-28 10:26 ~ Backup complete. -' - 14.5G (/dev/mmcblk0)' backed up to -'/mnt/extra/system_backup/backup/shrinked/rPI_28032023.img' -14.4gb reduced to 6.21gb in 26 min 4 sec.

content of /usr/local/bin:

root@rPi:/usr/local/bin# ls
google-oauthlib-tool gphotos-sync pisafe pishrink.sh pyrsa-decrypt pyrsa-encrypt pyrsa-keygen pyrsa-priv2pub pyrsa-sign pyrsa-verify
root@rPi:/usr/local/bin#

What is the solution to avoid downloading pishrink every time?

Thanks!

cron job issue when new version checking

Hi again. I found one more issue.

I use pi-safe as cron task and rexpect unattending work, but today I found 100% busy pisafe task which was had run two days ago. I killed it and backup process continue and completed sucessfully. After my manual execution of pisafe I see:

pisafe
PiSafe: UPDATE AVAILABLE: Update PiSafe from '1.2.2' to '1.2.3' [y/n]?Updating PiSafe to v 1.2.3...
1.2.3 installed. Press any key to exit...

Can you not lock work with a wait of response please when script running with a parameters? I will be appreciated you a lot.

Script does not allow saving to external mounted drive

Hi, I would like to save backup to mounted external drive /srv/dev-disk-by-uuid-1ff0486f-334e-4abc-b2ee-eb347354bfad but pi-safe checks only free space on /root, and does not check if directory is mounted drive with different size.

Is there possibility to do this?

Thanks for your effort!

image

Ignore specific partitions?

Hello dear developer!
i have a weird situation where i'm using a single hdd with 3 partitions (boot, OS, share). Is there any way to ignore the share partition and backup the boot + OS?
dev/sda with sda1 (boot), sda2 (OS), sda3 (share)

can't find SD card

I have my RPI4 booted from a USB SSD. After booting I plug in a MicroSD card that I was to run Pisafe on. However, Pisafe can't recognize that SD. Not sure if the SD has to be using a USB SD card adapter or what?

USBoot Backup?

Just wondering will this also allow backup of a boot usb drive as I don't use a microsd, to be backedup to an external storage drive e.g usb drive?

pi-safe help contains spelling errors

Let me start off by saying I'm enjoying your app!

While reviewing the help section for tips on how to use pi-safe from CLI, and not via the GUI, I noticed there were some spelling errors. See below.

Corrections listed in-line:
PiSafe v0.9.21 - Designed for Raspberry Pi

  • Backup your SD card to an image file
  • Restore your SD card from an image file

Usage:
pisafe [function] [device/file] [file/device]

Function is:
- startup the gui menu (this is recomended) <-- recommended is spelled with two m's
list - list SD-devices and image-files
backup [device] [file] - backup SD-card to image-file
restore [file] [device] - restore image-file to SD-card
install - install this script
update - update script from webiste <-- Should be changed to website (i and s reversed)
-v - display version
help | -h - help

Notes:

  • Supports .img .zip .xz and .gz files. Appends '.img.img' if no extension is specified
  • Specifying an '.img' extension is faster, but twice the size because it is not compressed with img.

Examples:
pisafe
pisafe list
pisafe backup sda newimage
pisafe backup /dev/sdb newimage.xz
pisafe restore newimage.img.zip sda

Note: This issue doesn't break app functionality, but the spelling errors should be corrected at some point, as it looks bad.

Any way to use it on Windows (or WSL)?

Hi, first thanks a lot for your work on that awsome tool.

I have a lot of things in mind and suggestions, but I will first start with my main point.
I tried someway to use Pisafe, but having my pc on windows I have to boot a live linux each time wich makes the process quite slow.
I tried to use it on WSL, it runs, but it can't detect my micro sd card.
I also tried on a virtual machine, but there again I can't make it see my micro sd card.

On WSL I can see my card sd card on /mnt with also all my other drives. I thought it could be a simple path to add when the tool search to list the drives. I hope it could be easy, I guess WSL could be the easiest way to use it on windows for now as it's all bash.

Thanks

Difficult to distinguish which volume is the source, which the target

I had trouble figuring out which disk was the source, which the target. Youtube videos of an earlier(?) version showed this explicitly called out in the character-cell UI. Can you either update the README to point out which is which in the current UI, and/or add it to the UI in the next update?

Problem shrinking Raspi-Endeavouros SDCard.

Hi Richard,

Are you all right?

I'm still using "PiSafe 1.2.5 i". Is this the right choice for me (remember, brazilian portuguese)?

Today I'm trying to backup a new OS, Endeavour OS.

It has a different way to get the OS on SDCard. By this reason I'd like to have a backup.

But shrinking is failing and I'm not sure restoring would be ok.

The difference I can see is that partitions are GPT.

Let me know what is going on.

Thanks and see you.

Take a look on fdisk:

Disco /dev/sdd: 29,72 GiB, 31914983424 bytes, 62333952 setores
Disk model: STORAGE DEVICE
Unidades: setor de 1 * 512 = 512 bytes
Tamanho de setor (lógico/físico): 512 bytes / 512 bytes
Tamanho E/S (mínimo/ótimo): 512 bytes / 512 bytes
Tipo de rótulo do disco: gpt
Identificador do disco: 61DFB242-2BB9-426E-B6A6-3F292848CE81

Dispositivo Início Fim Setores Tamanho Tipo
/dev/sdd1 4096 413695 409600 200M Microsoft dados básico
/dev/sdd2 413696 62330879 61917184 29,5G Linux sistema de arquivos


Take a look on pisafe output:

PiSafe 1.2.5 i
Checking for PiSafe updates...
PiSafe 1.2.5 i Backup...
No extension specified. Adding '.img.zip'
OUT-FILE='/home/vieira/Downloads/ISOs/endeavouros-basic.img.zip'
29.7gb to read from '/dev/sdd'
113gb available space on '/home/vieira/Downloads/ISOs'

~ PiSafe 1.2.5 i Backup '/dev/sdd' to '/home/vieira/Downloads/ISOs/endeavouros-basic.img.zip'
~ Step 1 of 3 - Copying '/dev/sdd' to '/home/vieira/Downloads/ISOs/endeavouros-basic.img' ...
qua 29 jun 2022 21:12:12 -03
Media size=29.7gb
Skipping 1.50mb of freespace at end of media.
Reading 29.7gb...
~ Running: sudo pv /dev/sdd -p -s 31913410560 | sudo dd bs=4194304 of='/home/vieira/Downloads/ISOs/endeavouros-basic.img' count=7609 iflag=fullblock conv=fsync
7609+0 registros de entrada==============================================> ] 99%
7609+0 registros de saída
31914459136 bytes (32 GB, 30 GiB) copiados, 630,515 s, 50,6 MB/s
[========================================================================>] 100%
Done copying media '/dev/sdd'
'30G /home/vieira/Downloads/ISOs/endeavouros-basic.img'
Step 1 took 10 min 36 sec

~ Step 2 of 3 - Shrinking filesystem ...
~ Running: sudo pishrink.sh -s '/home/vieira/Downloads/ISOs/endeavouros-basic.img'
pishrink.sh v0.1.2
pishrink.sh: Gathering data ...
Error: end of file while reading /home/vieira/Downloads/ISOs/endeavouros-basic.img
pishrink.sh: ERROR occurred in line 281: parted failed with rc 1
pishrink.sh: Possibly invalid image. Run 'parted /home/vieira/Downloads/ISOs/endeavouros-basic.img unit B print' manually to investigate ...
~ Exit_Status 6 running 'sudo pishrink.sh -s '/home/vieira/Downloads/ISOs/endeavouros-basic.img' '
~ Continuing without shrinking the file system...
Done shrinking filesystem.
'30G /home/vieira/Downloads/ISOs/endeavouros-basic.img'
Step 2 took 0 min 5 sec

~ Step 3 of 3 - Compressing '/home/vieira/Downloads/ISOs/endeavouros-basic.img' to '/home/vieira/Downloads/ISOs/endeavouros-basic.img.zip' ...
qua 29 jun 2022 21:22:53 -03
Compression set to level 5 of 9
29.7gb to compress.
Each dot=608m
/home/vieira/Downloads/ISOs/endeavouros-basic.img [........................|.........................] 100%
~ Running: zip -dbds 608m -m -5 '/home/vieira/Downloads/ISOs/endeavouros-basic.img.zip' '/home/vieira/Downloads/ISOs/endeavouros-basic.img'
[ 0/ 29G] adding: home/vieira/Downloads/ISOs/endeavouros-basic.img .................................................. (deflated 68%)
Done compressing '/home/vieira/Downloads/ISOs/endeavouros-basic.img' to '/home/vieira/Downloads/ISOs/endeavouros-basic.img.zip'
9,6G /home/vieira/Downloads/ISOs/endeavouros-basic.img.zip
Step 3 took 19 min 54 sec
Press any key to return

Command line options to automate backups

_I run a few pi's 24x7 and have backup solutions in place for databases and such but nothing for the os itself, this seems to be a very good method of backing up the os to an image for fast recovery.

It would be great to use this backup method via the cron using command line parameters, is this something of consideration?_

EDIT: Apologies, I really should have looked at the code first, watch the video and gained the impression this was only usable via the menu, especially with the additional confirmations and countdown. But I see in the code it expects parameters, maybe just a parameter to turn off the confirmation is all that's needed.

Thanks

Virtualbox on Windows-sdcard not found

Hello,
I've been trying to get my windows virtualbox to find recognize my usb sdcard reader with no luck. It was mentioned in the active issue that you were able to run it in Windows without an issue. The option to attach the usb does not come up and trying to create a vmdk file keeps giving me an error. Do you remember doing anything to get windows to recognize the usb sd card reader?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.