diff options
author | Dave Reisner <d@falconindy.com> | 2010-06-08 08:55:21 -0400 |
---|---|---|
committer | Dave Reisner <d@falconindy.com> | 2010-06-08 08:55:21 -0400 |
commit | 0dca065f3a35c7fb1c56629ab484691e6b22019f (patch) | |
tree | 5d3ee1410690c989bd4e906db8e02ee71924b6c9 /squashfu | |
parent | e6101ea8ae7fb640c3148f452f55ec07ee271e0a (diff) | |
download | squashfu-0dca065f3a35c7fb1c56629ab484691e6b22019f.tar.gz |
restore: handle directories separately
* in the case of a directory, copy the contents of the restore target to
a new directory and chown it back to the original UID:GID.
* use %Y%m%d as a suffix on the restored file instead of seconds from
epoch.
Diffstat (limited to 'squashfu')
-rwxr-xr-x | squashfu | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -356,6 +356,7 @@ action_restore () { IFS=$'\n' read -r -d $'\0' -a results < <(find $BINS_DIR/*/$(dirname $1)/$(basename $1) -maxdepth 0 2>/dev/null) [[ ${#results[@]} -eq 0 ]] && die "Target not found: '$1'" + local restore_type=$(stat -c %F ${results[0]}) declare -a snaps @@ -382,10 +383,16 @@ action_restore () { mount_squash || die "Failed to mount seed" mount_union_with_bins ${bin_list[@]:0:$num} || die "Failed to mount union" - # XXX: Move the contents, not the dir (avoid extra subdir) - rsync -a "$UNION_MOUNT/$1" "$(basename $1).${snaps[$reply]}" + local restore_name="$1.$(date --date=@${snaps[$reply]} +%Y%m%d)" - info "Your $(stat -c %F "$UNION_MOUNT/$1") has been restored as ${PWD}/$(basename $1).${snaps[$reply]}" + { + if [[ -d "$UNION_MOUNT/$1" ]]; then + rsync -a $UNION_MOUNT/$1/* "$restore_name" && + chown $(stat -c %u:%g "$UNION_MOUNT/$1") "$restore_name"; + else + rsync -a "$UNION_MOUNT/$1" "$restore_name"; + fi + } && info "Your ${restore_type##regular } has been restored as ${restore_name}" unmount_all |