New answers tagged

0

Using fairly recent GNU versions of date, find, tar, and xargs: This script needs bash or ksh or zsh or some other reasonably modern shell that understands process substitution (<(...)) #!/bin/bash today='12am today' yesterday='12am yesterday' # function to create a tar file for a directory but only include # files older than "$2" but newer than "$...


0

Yes, using a pipe from gpg to tar, and tar can extract just one file, but you may have to read & decrypt most or all of the archive depending on where the wanted file is (start or end). The entire archive is not saved anywhere, but tar still has to search through it. Yes, keeping a list of & only saving the new & changed files for the incremental ...


0

If you always use this to copy only one file, you can create a shell function, possibly in your ~/.bashrc like cpb () { if [ -r "${2}/${1}~" ] ; then echo "backup of '$1' exists in '$2'" else cp -b "$1" "$2" fi } and use it like this: $ mkdir dir $ cpb x dir $ cpb x dir $ cpb x dir backup of 'x' exists in 'dir' $ ls -l dir ...


3

If you want to avoid clobbering any backup files with GNU cp, you can use numbered backups: cp --backup=t source destination Rather than overwrite a backup, this creates additional backups. Example As an example, let's consider a directory with two files: $ ls file1 file2 Now, let's copy file1 over file2: $ cp --backup=t file1 file2 $ ls file1 ...


1

The target disk must be a few kB smaller than the source disk. “500 GB” as a disk size means “at least 500,000,000,000 bytes”; you can't count on all 500 GB disks to have exactly the same number of bytes. Since all the partitions have the same size and position, the part at the end that doesn't fit isn't used anyway, so this isn't a problem. 45 MB/s is ...


0

You can combine two -exec operation of find, firstly to find all files containing matching string and secondly to replace the string with replace keyword (keeping backup of original file), like find . -type f -exec grep -il "searchstring" {} \; -exec sed -i.bak \ 's/searchstring/replacestring/' {} \; Explanation : -exec grep -il "searchstring" : search ...


0

It will be at least hard to do a proper backup over FTP. Try connect with SSH, and then you can run tar -zcvf backup.tar.gz / Then you can download your archive file from the server using FTP if you want. Notice: make sure that you have enough space on the disk for the entire backup before, or you can find out your system drive full!


1

If you have an USB stick bigger than 4 GB and you want to put big files on it, try NTFS. (You could also use Ext[234], but you wouldn't be able to read it on Windows, while NTFS naturally works on Windows). No more worrying if your file is bigger or smaller than than 4GB. Some graphical formatting programs will suggest NTFS as an option, otherwise man mkfs....


0

A Guaranteed way to do this is to use BIT 4 BIT Cloning. This makes an image the exact same size as this drive, but should guarantee that your new pen drive will act the exact same way. When you get to the first Clonezilla screen Choose Dev-Disk not Dev-part/image. This takes more time and more space of course, but with a pen drive, I don't imagine it ...


2

I like to be pragmatic, and since writing a zsh completion is outside my current skills, I'd just write a special purpose function using the select menu system from zsh (and bash). cdd(){ typeset dir typeset -a dirs if [[ $PWD =~ ^(.*)(/back-[0-9-]+T[0-9_]+/)(.*)$ ]] then for dir in "$match[1]"/*/"$match[3]" do [ "$dir" !=...


3

One way to exchange one directory component for another in zsh is the two-argument version of cd: cd old new This substitutes new for the first substring matching old and tries to change directory to the resulting path. For example: % pwd /path/to/my/backup/back-2015-07-02T21_18_01/home/myuser/myfiles/somedir/subdir/ % cd "5-07-02T21_18_01" "6-04-...


6

setfacl is designed to accept getfacl output as input. Meaning you can run getfacl, save the output to a file, do your thing, then restore the ACL. The exact procedure can vary depending on your platform. On Linux though: # Take a peek at the current ACL [root@vlp-fuger ~]# getfacl newFile # file: newFile # owner: root # group: root user::rw- group::r-- ...


0

Try entr command-line tool which can run arbitrary commands when files change. Since 2.9 release, a directory watch option (-d) was added to react to events when a new file is added to a directory. Example to run the utility if a new file is added to the project: $ while true; do > echo src/* | entr -d your_command > done In directory watch mode ...


0

I thought of one way. Unfortunately it doesn't resume so it kind of assumes you don't mind leaving your computer on. Not tested either. EDIT: woops, terdon's revised answer is much better. SRC=src # source directory DEST=dest # target directory LOCKFILE=/var/tmp/copy.lock BATCH_LEN=5m # 5 minutes BATCH_DELAY=5m touch "$LOCKFILE" (cd "$SRC" && ...


2

rsync has an option to limit the throughput; for example --bwlimit=1 is 1 kibibyte/second. Use a suffix of K M or G to multiply the number, the default being K. The man page talks about sockets, but it applies to local copies too. You can try running sudo smartctl -a /dev/sdx on your disk sdx to see if there are any indications of it suffering from over-...


2

Not particularly elegant, but you could run your copy command and then run a loop that pauses it for, say 3 minutes every 20 minutes: Launch your copy command in the background cp -r /path/to/dir /path/to/external/drive & Run this loop which will stop/restart it: while ps -p $! >/dev/null; do kill -SIGCONT $!; sleep 20m; kill -s ...


0

I would expect you could run an incremental update without running verify first. The man page says Duplicity does not require access to archive files except when restoring from backup. but based on my testing verify (at least) counts as a kind of restoring.


0

The easiest way to do this is with two USB drives. or a CD-ROM and a USB drive. One can be quite small to hold a bootable Clonezilla system (needs only a few hundred MB). The smallest USB thumb drive you can buy will be more than enough. Or burn it to a CD-ROM (but CDs are more fragile and booting & running from CD is slower than USB). The second ...


1

You can use squashfs to make a squashed version of your filesystem. First check if squashfs-tools is installed or not. I don't know the exact name of the package. So look up google to install it on your Ubuntu. After you install it, run- sudo mount /dev/xxx /mnt (Replace xxx with the proper partition name. This must be the partition where your OS is ...


1

The usual method is (writing from memory): NEWBACKUP=`date +%s` # or some other format cp -al "$OLDBACKUP" "$NEWBACKUP" rsync -aH --delete "$SOURCE" "$NEWBACKUP" Check out Easy Automated Snapshot-Style Backups with Linux and Rsync There is also a --link-dest option to rsync that I've never investigated properly.


1

The command tar czf /media/masi/ntfsDisc/backup_home.tar.gz $HOME/ is the same as this: tar cf - $HOME/ | gzip > /media/masi/ntfsDisc/backup_home.tar.gz When you ran top, it showed the gzip was using up around 100% of one cpu thread. The NTFS FUSE software is using up a nonzero amount of CPU, too, but essentially you're CPU-bound because of that ...



Top 50 recent answers are included