This commit is contained in:
parent
1496eefc14
commit
2e372d1aae
18
Makefile
18
Makefile
@ -8,6 +8,8 @@ REMOTE_CONTAINER_PATH=/data/db/mongodump
|
|||||||
LOCAL_PATH=/tmp/mongodump
|
LOCAL_PATH=/tmp/mongodump
|
||||||
LOCAL_DB=test
|
LOCAL_DB=test
|
||||||
LOCAL_CONTAINER_NAME=nextload-mongo-1
|
LOCAL_CONTAINER_NAME=nextload-mongo-1
|
||||||
|
REMOTE_VOLUME_NAME = nextload-demo_autonomic_zone_payload_uploads
|
||||||
|
LOCAL_VOLUME_NAME = nextload_payload_uploads
|
||||||
ENV_FILE=.env
|
ENV_FILE=.env
|
||||||
|
|
||||||
include $(ENV_FILE)
|
include $(ENV_FILE)
|
||||||
@ -29,3 +31,19 @@ sync_db:
|
|||||||
|
|
||||||
@echo "Step 4: Drop the existing local database and restore the dump"
|
@echo "Step 4: Drop the existing local database and restore the dump"
|
||||||
docker exec -it $(LOCAL_CONTAINER_NAME) mongorestore --drop --username $(MONGO_USER) --password $(MONGO_PASSWORD) --authenticationDatabase admin --db $(LOCAL_DB) /tmp/mongodump/$(LOCAL_DB)
|
docker exec -it $(LOCAL_CONTAINER_NAME) mongorestore --drop --username $(MONGO_USER) --password $(MONGO_PASSWORD) --authenticationDatabase admin --db $(LOCAL_DB) /tmp/mongodump/$(LOCAL_DB)
|
||||||
|
|
||||||
|
sync_media:
|
||||||
|
@echo "Step 1: Create a tar archive of the remote Docker volume"
|
||||||
|
rm -rf /tmp/$(REMOTE_VOLUME_NAME)
|
||||||
|
mkdir -p /tmp/$(REMOTE_VOLUME_NAME)
|
||||||
|
ssh -p $(REMOTE_PORT) $(REMOTE_USER)@$(REMOTE_SERVER) \
|
||||||
|
"docker run --rm -v $(REMOTE_VOLUME_NAME):/volume -v /tmp:/backup alpine tar -czf /backup/$(REMOTE_VOLUME_NAME).tar.gz -C /volume ."
|
||||||
|
|
||||||
|
@echo "Step 2: Copy the media from remote volume to local volume"
|
||||||
|
scp -P $(REMOTE_PORT) $(REMOTE_USER)@$(REMOTE_SERVER):/tmp/$(REMOTE_VOLUME_NAME).tar.gz /tmp/$(REMOTE_VOLUME_NAME).tar.gz
|
||||||
|
docker run --rm -v /tmp:/volume -v $(LOCAL_VOLUME_NAME):/backup alpine tar -xzf /volume/$(REMOTE_VOLUME_NAME).tar.gz -C /backup
|
||||||
|
|
||||||
|
@echo "Step 3: Cleanup temporary files"
|
||||||
|
rm /tmp/$(REMOTE_VOLUME_NAME).tar.gz
|
||||||
|
|
||||||
|
@echo "Media synchronization complete."
|
Loading…
Reference in New Issue
Block a user